1 条题解

  • 0
    @ 2024-12-24 9:48:47

    C :

    #include <stdio.h>
    int main(){
        int total, n, r3, r5, r7;
        int i, a, b, c, flag;
        scanf("%d", &n);
        while(n--){
            scanf("%d %d %d",&a,&b,&c);
            flag = 0;
            for(total = 10; total <= 100; total++){
                r3 = total % 3;
                r5 = total % 5;
                r7 = total % 7;
                if(r3 == a && r5 == b && r7 == c){
                    flag = 1;
                    break;
                }
            }
            if(flag) printf("%d\n",total);
            else puts("No Answer");
        }
        return 0;
    }
    

    C++ :

    #include<iostream>
    using namespace std;
    int main()
    {
    	int n,a,b,c,ans;
    	cin>>n;
    	for(int i=0;i<n;i++)
    	{
    		cin>>a>>b>>c;
    		if (a>3 || b>5 || c>7){cout<<"No Answer"<<endl;	}
    		else{
    			ans=a*70+21*b+15*c;
    		while(ans>105)
    		ans-=105;
    		if(ans>=10&&ans<=100) cout<<ans<<endl;
    		else cout<<"No Answer"<<endl;
    		}
    		
    	}
    	
    	return 0;
    }
    

    Java :

    import java.util.*;
    public class Main {
    	public static void main(String[] args) {
    		Scanner input=new Scanner(System.in);
    		int n=input.nextInt();
    		while(n>0) {
    			int t3=input.nextInt();
    			int t5=input.nextInt();
    			int t7=input.nextInt();
    			if(t3>=3||t5>=5||t7>=7) {
    				System.out.println("No Answer");
    				n--;
    				continue;
    			}
    			for(int i=10;i<=100;i++) {
    				if((i-t3)%3==0&&(i-t5)%5==0&&(i-t7)%7==0) {
    					System.out.println(i);
    					break;
    				}
    			}
    			n--;
    		}
    
    	}
    
    }
    
    • 1

    信息

    ID
    658
    时间
    3000ms
    内存
    128MiB
    难度
    (无)
    标签
    递交数
    0
    已通过
    0
    上传者