結果
問題 | No.403 2^2^2 |
ユーザー |
![]() |
提出日時 | 2025-03-26 16:01:37 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 1 ms / 2,000 ms |
コード長 | 599 bytes |
コンパイル時間 | 504 ms |
コンパイル使用メモリ | 28,160 KB |
実行使用メモリ | 5,888 KB |
最終ジャッジ日時 | 2025-03-26 16:01:53 |
合計ジャッジ時間 | 1,461 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 27 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:25:19: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 25 | int a,b,c; scanf("%lld^%lld^%lld",&a,&b,&c); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include<cstdio>#define int long longusing namespace std;const int M=1e9+7,P=1000000013000000042; bool flag;int mul(int a,int b,int p) {int ans=0;while(b) {if(b&1) {ans+=a;if(ans>=p) flag=true,ans%=p;}(a+=a)%=p,b>>=1;}return ans;}int power(int a,int b,int p) {int ans=1;while(b) {if(b&1) ans=mul(ans,a,p);a=mul(a,a,p),b>>=1;}return ans;}signed main() {int a,b,c; scanf("%lld^%lld^%lld",&a,&b,&c);printf("%lld ",power(power(a,b,M),c,M));flag=false; int k=power(b,c,P)+P*flag;printf("%lld",power(a,k,M));return 0;}