typedef unsigned long u64;
struct DuckInfo { u64 abi_version; const char *stdin_ptr; u64 stdin_size; char *stdout_ptr; u64 stdout_limit; u64 stdout_size; char *stderr_ptr; u64 stderr_limit; u64 stderr_size; const char *IB_ptr; u64 IB_limit; char *OB_ptr; u64 OB_limit; u64 tsc_frequency; } __attribute__((packed));
#define MOD 1000000007ull
static u64 pw(u64 b, u64 e){
u64 r=1; b%=MOD;
while(e){ if(e&1) r=r*b%MOD; b=b*b%MOD; e>>=1; }
return r;
}
int __libc_start_main(int (*m)(int,char**,char**), int argc, char **argv, void*i,void*f,void*r) {
char **envp = argv + argc + 1;
while (*envp) envp++;
long *auxv = (long*)(envp + 1);
struct DuckInfo *d = 0;
while (auxv[0] != 0) { if (auxv[0] == 0x6b637564) { d = (struct DuckInfo*)auxv[1]; break; } auxv += 2; }
const char *in = d->stdin_ptr;
int n=0; while (*in >= '0' && *in <= '9') { n=n*10+(*in-'0'); in++; }
while (*in==' '||*in=='\n'||*in=='\r'||*in=='\t') in++;
int mm=0; while (*in >= '0' && *in <= '9') { mm=mm*10+(*in-'0'); in++; }
if (n > mm) { int t=n; n=mm; mm=t; }
u64 ans;
if (n==1) ans = pw(2, mm);
else if (n==2) ans = 4*pw(3, mm-1)%MOD;
else if (n==3) ans = 112*pw(3, mm-3)%MOD;
else if (mm<=8) {
// tab[n][mm]
static const int tab[9][9] = {
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,8,36,112,336,1008,3024,9072,27216},
{0,16,108,336,912,2688,8064,24192,72576},
{0,32,324,1008,2688,7136,21312,63936,191808},
{0,64,972,3024,8064,21312,56768,170112,510336},
{0,128,2916,9072,24192,63936,170112,453504,1360128},
{0,256,8748,27216,72576,191808,510336,1360128,3626752},
};
ans = tab[n][mm];
} else if (n==8) ans = 10879488ull*pw(3, mm-9)%MOD;
else {
static const int t8[9] = {0,0,0,27216,72576,191808,510336,1360128,0};
ans = t8[n]*pw(3, mm-8)%MOD;
}
char buf[16]; int len=0;
if (ans==0) { buf[len++]='0'; } else { char tmp[16]; int t=0; while(ans){ tmp[t++]=ans%10+'0'; ans/=10; } while(t--) buf[len++]=tmp[t]; }
buf[len++]='\n';
char *out = d->stdout_ptr;
for (int k=0;k<len;k++) out[k]=buf[k];
d->stdout_size = len;
__asm__ volatile("syscall" : : "a"(60), "D"(0) : "memory");
__builtin_unreachable();
}
int main(){ return 0; }
| Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
| Testcase #1 | 2.96 us | 8 KB | Accepted | Score: 5 | 显示更多 |
| Testcase #2 | 2.68 us | 8 KB | Accepted | Score: 5 | 显示更多 |
| Testcase #3 | 2.58 us | 8 KB | Accepted | Score: 5 | 显示更多 |
| Testcase #4 | 2.66 us | 8 KB | Accepted | Score: 5 | 显示更多 |
| Testcase #5 | 3.14 us | 8 KB | Accepted | Score: 5 | 显示更多 |
| Testcase #6 | 3.08 us | 8 KB | Accepted | Score: 5 | 显示更多 |
| Testcase #7 | 3.13 us | 8 KB | Accepted | Score: 5 | 显示更多 |
| Testcase #8 | 3.22 us | 8 KB | Accepted | Score: 5 | 显示更多 |
| Testcase #9 | 3.07 us | 8 KB | Accepted | Score: 5 | 显示更多 |
| Testcase #10 | 2.92 us | 8 KB | Accepted | Score: 5 | 显示更多 |
| Testcase #11 | 3.21 us | 8 KB | Accepted | Score: 5 | 显示更多 |
| Testcase #12 | 3.25 us | 8 KB | Accepted | Score: 5 | 显示更多 |
| Testcase #13 | 3.08 us | 8 KB | Accepted | Score: 5 | 显示更多 |
| Testcase #14 | 2.83 us | 8 KB | Accepted | Score: 5 | 显示更多 |
| Testcase #15 | 3.2 us | 8 KB | Accepted | Score: 5 | 显示更多 |
| Testcase #16 | 3.1 us | 8 KB | Accepted | Score: 5 | 显示更多 |
| Testcase #17 | 3.1 us | 8 KB | Accepted | Score: 5 | 显示更多 |
| Testcase #18 | 2.93 us | 8 KB | Accepted | Score: 5 | 显示更多 |
| Testcase #19 | 2.48 us | 8 KB | Accepted | Score: 5 | 显示更多 |
| Testcase #20 | 3.02 us | 8 KB | Accepted | Score: 5 | 显示更多 |