QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#88375#5791. Multi-base happinessunputdownable27 ✓2613ms91420kbC++171.7kb2023-03-16 09:10:272023-03-16 09:10:30

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-03-16 09:10:30]
  • 评测
  • 测评结果:27
  • 用时:2613ms
  • 内存:91420kb
  • [2023-03-16 09:10:27]
  • 提交

answer

// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2")
#include <bits/stdc++.h>
// #define int long long
#define i64 long long
#define pii pair <int, int> 
using namespace std;
char White;
inline int read(void) {
    int x=0,sgn=1; char ch=getchar();
    while(ch<48||57<ch) {if(ch==45)sgn=0;ch=getchar();}
    while(47<ch&&ch<58) {x=x*10+ch-48;   ch=getchar();}
    White=ch; return sgn? x:-x;
}
void write(int x) {
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
}
const int Lim=5000000;
short res[11][Lim+2],*vis,k;
int b[12],cntb;
inline int trans(int x) {
    if(x>=k) return (x%k)*(x%k)+trans(x/k);
    return x*x;
}
inline int dfs(int x) {
    if(!vis[x]) {
        vis[x]=3;
        return vis[x]=dfs(trans(x));
    }
    if(vis[x]==3) return vis[x]=2;
    return vis[x];
}
signed main() {
    for(int base=2; base<=10; ++base) {
        vis=res[base]; k=base;
        vis[1]=1; const int L=base*base*base;
        for(int i=2; i<=L; ++i) dfs(i);
        for(int i=L+1; i<=Lim; ++i) vis[i]=vis[trans(i)];
    }
    fprintf(stderr,"%.4lf\n",1.0*clock()/CLOCKS_PER_SEC);
    int T=read();
    for(int t=1; t<=T; ++t) {
        b[cntb=1]=read();
        while(White!='\n') b[++cntb]=read();
        bool gg=1;
        for(int i=2; i<=Lim; ++i) if(res[b[cntb]][i]==1) {
            gg=0;
            for(int u=1; u<cntb; ++u) if(res[b[u]][i]==2) gg=1; 
            if(!gg) {
                printf("Case #%d: %d\n",t,i);
                break;
            }
        } 
        if(gg) printf("Case #%d: 11814485\n",t);
    }
    return 0;
}

详细

Subtask #1:

score: 9
Accepted

Test #1:

score: 9
Accepted
time: 2264ms
memory: 91420kb

input:

42
7 10
6 7 8
2 4 7
4 7 9
2 10
6 7 9
7 8 9
2 3 8
3 10
4 7
8 10
3 4
3 6 10
3 4 7
6 9
2 5 10
7 9 10
3 6 8
2 8 9
2 7 8
2 5 6
2 6 9
2 4 9
4 5 8
2 3 5
4 7 10
3 7 10
2 4 6
3 6
3 6 9
4 9
4 8 9
3 8 10
4 5 6
2 6
5 8
3 4 6
6 10
2 4 8
2 8 10
7 8 10
5 6 10

output:

Case #1: 7
Case #2: 47089
Case #3: 7
Case #4: 125
Case #5: 7
Case #6: 2753
Case #7: 6393
Case #8: 27
Case #9: 13
Case #10: 7
Case #11: 97
Case #12: 3
Case #13: 79
Case #14: 143
Case #15: 415
Case #16: 7
Case #17: 1337
Case #18: 3879
Case #19: 27
Case #20: 1001
Case #21: 49
Case #22: 415
Case #23: 3
...

result:

ok 42 lines

Subtask #2:

score: 18
Accepted

Test #2:

score: 18
Accepted
time: 2613ms
memory: 91420kb

input:

500
2 3 4 7 8 9
2 3 5 7 9 10
3 5 9
2 5 7 8 9
3 4 7 9 10
2 3 5 6 7 8 10
2 3 4 5 6 7 8
2 7 8 9
2 3 4 9 10
3 4 5 7 8 10
5 6 8
2 3 4 5 7 8 10
2 4 6 7 9 10
4 5 6 7 9
2 3 4 10
2 3 4 5 7
2 3 6 9
2 3 5 6 9
2 4 5 10
2 4 6 7 8
5 6 7 8
3 5 6 7 10
2 4 5 7 8 9 10
2 3 8 9 10
2 3 6 7 8
2 6 7 8 9 10
2 3 4 6 9 10
3 ...

output:

Case #1: 35785
Case #2: 120149
Case #3: 27
Case #4: 6393
Case #5: 1337
Case #6: 2688153
Case #7: 58775
Case #8: 6393
Case #9: 91
Case #10: 120407
Case #11: 1975
Case #12: 120407
Case #13: 71735
Case #14: 37131
Case #15: 13
Case #16: 143
Case #17: 707
Case #18: 1695
Case #19: 7
Case #20: 47089
Case #...

result:

ok 500 lines

Extra Test:

score: 0
Extra Test Passed