5 solutions

  • 2
    @ 2022-2-6 20:18:50

    直接暴力,不需要分类讨论

    #include<stdio.h> int main(){ int a,b,c,x,y; int flag = 0; scanf("%d %d %d",&a,&b,&c); for(x=0; x<=10000; x++){ for(y=0; y<=10000; y++){ if(ax+by+c == 0){ flag++; } } } printf("%d",flag); }

    • 1
      @ 2021-12-6 20:08:10

      用一手floor函数

      #include<bits/stdc++.h>
      using namespace std;
      int main(){
      	int a,b,c;
      	scanf("%d %d %d",&a,&b,&c); 
      	double x;
      	int flag=0;
      	for(int y=0;y<10001;y++){
      		x=(-b*(double)y-c)/a;
      		if(x>=0&&x<=10000&&floor(x+0.5)==x){
      			flag++;
      		}
      	}
      	cout<<flag;
      	return 0;
      }
      
      • 0
        @ 2024-12-15 11:33:16

        #include <stdio.h>

        int main() { int count=0,a, b, c, x, y; scanf("%d %d %d", &a, &b, &c); for(x=0;x<=10000;x++) { for(y=0;y<=10000;y++) { if((ax+by+c)==0){count++;} } } printf("%d", count); return 0; }

        • 0
          @ 2022-3-18 22:14:28

          我的评价是,直接枚举。

          #include <bits/stdc++.h>
          using namespace std;
          #define ll long long
          
          
          int main()
          {
          	int a,b,c;
          	cin>>a>>b>>c;
          	int ans=0;
          	for(int i = 0; i <= 10000; i++){
          		for(int j = 0; j <= 10000; j++){
          			if(a*i+b*j+c == 0)	ans++;
          		}
          	}
          	cout << ans << endl; 
            	return 0;
          }
          
          • 0
            @ 2021-10-17 15:01:35

            小白写法,分类讨论

            #include <stdio.h>
            int main() {
            	long long  a, b, c, sum = 0, sum2 = 0, temp=0;
            	scanf("%lld %lld %lld", &a, &b, &c);
            	if (b != 0) {
            		for (int y = 0; y <= 10000; y++) {
            			for (int x = 0; x <= 10000; x++) {
            				if (y == -(c + a * x)*1.0/ b) sum += 1;
            			}
            		}
            	}else if (a * c > 0) sum = 0;
            	else if (a==0&&c==0) sum = 10001 * 10001;
            	else if (a==0&&c!=0) sum =0;
            	else if (a*c < 0) sum = 10001;
            	printf("%lld\n", sum);
            	return 0;
            }
            
            • @ 2021-10-17 15:08:32

            • @ 2022-2-6 20:19:45

              不需要分类讨论呀,直接暴力就行了

          • 1

          Information

          ID
          48
          Time
          1000ms
          Memory
          256MiB
          Difficulty
          5
          Tags
          # Submissions
          381
          Accepted
          140
          Uploaded By