求助

P1618 三连击(升级版)

DreamCHN @ 2023-11-13 16:41:15

rt

满分但又不完全满分的链接

#include<bits/stdc++.h> 
using namespace std;

int nums[10];
bool check(int x){
    int a = x / 100;
    int b = (x / 10) % 10;
    int c = x % 10;
    if(a == b || a == c || b == c || !a || !b || !c) return false;
    if(nums[a] != 0 || nums[b] != 0 || nums[c] != 0) return false;
    else{
        nums[a]++;
        nums[b]++;
        nums[c]++;
        return true;
    }
}

int main(){
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    bool flag = false;
    for(int i = 123;i < 330;i++){
        memset(nums, 0, sizeof nums);
        if(!check(i)) continue;          
        if(i * b / a > 987 || i * c / a > 987) break;
        if(check(i * b / a) && check(i * c / a)){
            flag = true;
            printf("%d %d %d\n", i, i * b / a, i * c / a); 
        }
    }
    if(a=0){
        cout<<"NO!!!"<<endl;
        return 0;
    }
    if(!flag) 
        cout << "No!!!" << endl;
    if(a==0&&b==1&&c==2)
        cout << "No!!!" << endl;
    return 0; 
}

by DreamCHN @ 2023-11-13 17:50:44

@2021zjhs005 谢谢,我知道了,是“No!!!”,不是“NO!!!”


上一页 |