zoukankan      html  css  js  c++  java
  • 求不定方程的所有解

    #include<stdio.h>
    int main()
    {
        int n,m,t;
        int a,b,c;
        int i,j;
        while(scanf("%d",&t)!=EOF)
        {
            while(t--)
            {
                int count=0;
                scanf("%d%d%d",&a,&b,&c);
                for(i=1;i<=c;i++)
                {
                    for(j=1;j<=c;j++)
                    {
                        if(a*i+b*j==c)
                        {
                            printf("%d %d
    ",i,j);
                            count++;
                        }
                    }
                }
                if(count==0)
                {
                    printf("No
    ");
                }
            }
        }
        return 0;
    }

    #include<stdio.h>
    int main()
    {
        int a, b, c, x, t, no;
        scanf("%d",&t);
        while(t--)
        {
            scanf("%d%d%d",&a,&b,&c);
            no=1;
            for(c-=a,x=1;c>=b;c-=a,x++)
                if(c%b==0)
                    no=0,printf("%d %d ",x,c/b);
            if(no)
                puts("No");
        }
        return 0;
    }

     

  • 相关阅读:
    页面性能
    js运行机制
    渲染机制
    通信类
    js面向对象 继承
    原型
    [HEOI2016/TJOI2016]求和
    「NOIP2018 保卫王国」
    「LGP4719【模板】动态dp」
    多项式进阶操作
  • 原文地址:https://www.cnblogs.com/zhouweibaba/p/10175016.html
Copyright © 2011-2022 走看看