110 条题解

  • -1
    @ 2009-10-31 00:59:42

    等价于求方程k(m-n)与(y-x)关于l同余,k为非负整数的解

    方程:

    k*(m-n)-ld=y-x

    若y-x不是gcd(m-n,l)的倍数输出impossible,否则用ext_gcd求出一个解,然后不断使得k+=l/gcd(m-n,l)直到>0或者k-=l/gcd(m-n,l)直到

  • -1
    @ 2009-10-12 22:04:15

    编译通过...

    ├ 测试数据 01:答案正确... 0ms

    ├ 测试数据 02:答案正确... 0ms

    ├ 测试数据 03:答案正确... 0ms

    ├ 测试数据 04:答案正确... 0ms

    ├ 测试数据 05:答案正确... 0ms

    ├ 测试数据 06:答案正确... 0ms

    ├ 测试数据 07:答案正确... 0ms

    ├ 测试数据 08:答案正确... 0ms

    ├ 测试数据 09:答案正确... 0ms

    ├ 测试数据 10:答案正确... 0ms

    ---|---|---|---|---|---|---|---|-

    Accepted 有效得分:100 有效耗时:0ms

    求ax+by=c的通解,

    a=-(m-n)

    b=l

    c=x-y

    因为x=(c-by)/a

    所以c-by=az

    将c和b都mod一下a同样成立,用此思想求出通解,然后求最优解

  • -1
    @ 2009-10-05 23:33:26

    康熙在此,何人敢如此胆大,胡编出此题,有损朕之盛名!

    (哈哈,开玩笑的,不过这题貌似不难,两次就过了)。。

  • -1
    @ 2009-09-12 17:03:21

    ?概念

    第一次

    编译通过...

    ├ 测试数据 01:答案正确... 0ms

    ├ 测试数据 02:答案错误... ├ 标准行输出

     ├ 错误行输出

    ├ 测试数据 03:答案错误... ├ 标准行输出

     ├ 错误行输出

    ├ 测试数据 04:答案错误... ├ 标准行输出

     ├ 错误行输出

    ├ 测试数据 05:答案错误... ├ 标准行输出

     ├ 错误行输出

    ├ 测试数据 06:答案错误... ├ 标准行输出

     ├ 错误行输出

    ├ 测试数据 07:答案错误... ├ 标准行输出

     ├ 错误行输出

    ├ 测试数据 08:答案错误... ├ 标准行输出

     ├ 错误行输出

    ├ 测试数据 09:答案错误... ├ 标准行输出

     ├ 错误行输出

    ├ 测试数据 10:答案错误... ├ 标准行输出

     ├ 错误行输出

    ---|---|---|---|---|---|---|---|-

    Unaccepted 有效得分:10 有效耗时:0ms

    第二次

    编译失败...|错误号:1

    MyProger\Prog98809.c:1:20: iostream: No such file or directory

    MyProger\Prog98809.c:2: error: syntax error before "namespace"

    MyProger\Prog98809.c:2: warning: data definition has no type or storage class

    MyProger\Prog98809.c: In function main':
    MyProger\Prog98809.c:5: error:
    cin' undeclared (first use in this function)

    MyProger\Prog98809.c:5: error: (Each undeclared identifier is reported only once

    MyProger\Prog98809.c:5: error: for each function it appears in.)

    MyProger\Prog98809.c:10: error: `cout' undeclared (first use in this function)

    #include

    using namespace std;

    long long int x,y,m,n,l,days;

    int main(){

    cin >>x>>y>>m>>n>>l;

    if (x>y){

    if (m>n){

    days=l-(x-y)/(m-n);

    if (days*(m-n)

  • -1
    @ 2009-09-12 08:51:40

    谁有数据啊?

  • -1
    @ 2009-08-28 15:35:15

    嗨,什么时候才能到c++的天下呀!!!

  • -1
    @ 2009-08-21 19:30:30

    100题纪念

  • -1
    @ 2009-08-15 16:02:14

    解线性同余方程x+kn≡y+km (mod L)。把方程整理一下成k(n-m)≡y-x (mod L),用拓展的欧几里德算法解出d=gcd(n-m,L)=s*(n-m)+t*L中的d和s。如果d能整除y-x的话方程有解,其中一个解是k0=s*(y-x)/d,而题目要求的是最小正整数解,由于方程相邻的两个解之差都等于v=L/d,所以最小正整数解应该是k=k0-[k0/v]*v。

    有两个细节需要注意:

    1) 好像Pascal的取模运算有点问题,用欧几里德算法求时余数可能为负数!所以如果为n

  • -1
    @ 2009-08-06 10:03:54

    BS 1S 没题解也发出来哦

  • -1
    @ 2009-08-05 16:32:00

    这题应该统一单位。。。。。。

信息

ID
1009
难度
8
分类
数论 点击显示
标签
递交数
6993
已通过
1057
通过率
15%
被复制
28
上传者