結果
| 問題 |
No.1448 和差算
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-03-30 23:09:51 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 549 bytes |
| コンパイル時間 | 1,647 ms |
| コンパイル使用メモリ | 166,232 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-30 23:29:05 |
| 合計ジャッジ時間 | 2,915 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 36 |
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:22:13: warning: 'ans' may be used uninitialized [-Wmaybe-uninitialized]
22 | cout<<(ans%mod*mod_pow(16,N/8)%mod+mod)%mod<<endl;
| ~~~^~~~
main.cpp:13:6: note: 'ans' was declared here
13 | ll ans;
| ^~~
ソースコード
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1000000007;
ll mod_pow(ll a,ll b){
if(!b)return 1;
if(b&1)return mod_pow(a,b-1)*a%mod;
ll c=mod_pow(a,b>>1);
return c*c%mod;
}
int main(){
ll A,B,C,D,N; cin>>A>>B>>C>>D>>N;
ll ans;
if(N%8==0)ans=B+D;
else if(N%8==1)ans=2*B;
else if(N%8==2)ans=2*B-2*C;
else if(N%8==3)ans=-4*C;
else if(N%8==4)ans=-4*A-4*C;
else if(N%8==5)ans=-8*A;
else if(N%8==6)ans=-8*A+8*D;
else if(N%8==7)ans=16*D;
cout<<(ans%mod*mod_pow(16,N/8)%mod+mod)%mod<<endl;
}