一个re,剩下的全部tle求调

P1618 三连击(升级版)

DSFineTony @ 2024-08-23 16:02:11

#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
    int a,b,c,cnt=0;
    cin>>a>>b>>c;
    for(int i=100;i<=999;i++){
        for(int j=100;j<=999;j++){
            for(int k=100;k<=999;k++){
                if(i/a==j/b==k/c){
                    cout<<i<<j<<k;
                    cnt=1;
                }
            }
        }
    }
    if(cnt=0){
        cout<<"No!!!";
    }
    return 0;
}

by machenchang @ 2024-10-02 20:49:15

40pts:

#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c,x,y,z,s;
    cin>>x>>y>>z;
    for(int i=123;i<=333;i++){
        a=i;
        a=i*x;
        b=i*y;
        c=i*z;
        if((a/100+a/10%10+a%10+b/100+b/10%10+b%10+c/100+c/10%10+c%10==1+2+3+4+5+6+7+8+9)&&((a/100)*(a/10%10)*(a%10)*(b/100)*(b/10%10)*(b%10)*(c/100)*(c/10%10)*(c%10)==1*2*3*4*5*6*7*8*9)){
            cout<<a<<" "<<b<<" "<<c<<endl;
            s++;
        }
    }
    if(s==0){
        cout<<"No!!!";
    }
    return 0;
}

by Arabidopsis @ 2024-11-12 08:23:52

暴力打法():

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Issues.QuestionList3
{
    internal class TripleTap
    {
        static bool[] used = new bool[10];
        static int[] fuckCCF = new int[10];
        static int a, b, c;
        static bool flag = false;
        public static void Run(string[] args)
        {
            var data = Console.ReadLine().Split(' ');

            a = Convert.ToInt32(data[0]);
            b = Convert.ToInt32(data[1]);
            c = Convert.ToInt32(data[2]);

            Dfs(1);

            if (!flag)
            {
                Console.WriteLine("No!!!");
            }
        }

        static void Dfs(int layer)
        {
            if (layer > 9)
            {
                var num1 = Convert.ToInt32($"{fuckCCF[1]}{fuckCCF[2]}{fuckCCF[3]}");
                var num2 = Convert.ToInt32($"{fuckCCF[4]}{fuckCCF[5]}{fuckCCF[6]}");
                var num3 = Convert.ToInt32($"{fuckCCF[7]}{fuckCCF[8]}{fuckCCF[9]}");

                if (num1 * c == num3 * a && num1 * b == num2 * a)
                {
                    Console.WriteLine($"{num1} {num2} {num3}");
                    flag = true;
                }

                return;
            }

            for (int i = 1; i < 10; i++)
            {
                if (!used[i])
                {
                    fuckCCF[layer] = i;
                    used[i] = true;
                    Dfs(layer + 1);
                    used[i] = false;
                }
            }
        }
    }
}

|