QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#746073 | #9628. 骰子 | Alucard | AC ✓ | 1ms | 3700kb | C++14 | 2.0kb | 2024-11-14 13:15:42 | 2024-11-14 13:15:43 |
Judging History
answer
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
#define i128 _int128
#define fi first
#define se second
#define pb push_back
#define endl '\n'
#define int long long
const ll INF=0x3f3f3f3f;
const ll N=1e8+9,M=1e9+9;
const int mod=1e9+7;
int read(){
int s=0,w=1;
char c=getchar();
while(!isdigit(c)) (c=='-')?w=-1:w=1,c=getchar();
while(isdigit(c)) s=(s<<1)+(s<<3)+(c^48),c=getchar();
return s*w;
}
int qpow(int a,int b){
a%=mod;
int res=1;
while(b){
if(b&1){res=(res*a)%mod;}
a=(a*a)%mod;
b>>=1;
}
return res%mod;
}
// int inverse(int a){
// a%=mod;
// return qpow(fac[a%mod],mod-2)%mod;
// }
// int C(int n,int r){
// n%=mod,r%=mod;
// if(r>n)return 0;
// return ((fac[n%mod]*inverse(r))%mod*inverse(n-r))%mod;
// }
// int Lucas(int n,int r){
// if(r==0)return 1;
// return C(n%mod,r%mod)%mod*Lucas(n/mod,r/mod)%mod;
// }
int n,m;
void solve(){
cin>>n>>m;
if(n!=1 && m!=1)cout<<n*m*6<<endl;
else{
int ans=6,idd=0;
if(n==1){
m-=1;
while(m--){
idd++;
if(idd==1)ans+=2;
else if(idd==2)ans+=4;
else if(idd==3)ans+=5;
else idd+=6;
idd%=4;
}
}
if(m==1){
n-=1;
while(n--){
idd++;
if(idd==1)ans+=3;
else if(idd==2)ans+=1;
else if(idd==3)ans+=4;
else idd+=6;
idd%=4;
}
}
cout<<ans<<endl;
}
}
signed main(){
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int _=1;
// fac[0]=1;
// for(int i=1;i<=N-9;++i)fac[i]=(fac[i-1]*i)%mod;
// cin>>_;
while(_--)solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3700kb
input:
2 2
output:
24
result:
ok single line: '24'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3640kb
input:
1000 1000
output:
6000000
result:
ok single line: '6000000'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3664kb
input:
987 654
output:
3872988
result:
ok single line: '3872988'