結果

問題 No.403 2^2^2
ユーザー akakimidori
提出日時 2017-05-07 16:55:00
言語 C90
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 498 bytes
コンパイル時間 143 ms
コンパイル使用メモリ 21,248 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-14 14:48:56
合計ジャッジ時間 1,050 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 19 WA * 8
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘run’:
main.c:18:3: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   18 |   scanf("%lld^%lld^%lld",&a,&b,&c);
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include<stdio.h>

typedef long long int ln;

int modPow(ln r,ln n,int mod){
  ln res=1;
  ln t=r;
  while(n>0){
    res=res*(n&0x01?t:1)%mod;
    t=t*t%mod;
    n>>=1;
  }
  return res;
}

void run(void){
  ln a,b,c;
  scanf("%lld^%lld^%lld",&a,&b,&c);
  const int mod=1000000007;

  int a_bc=modPow(a%mod,(int)((b%(mod-1))*c%(mod-1)),mod);
  int b_c=modPow(b%(mod-1),c,mod-1);
  int a_b_c=modPow(a%mod,b_c,mod);
  printf("%d %d\n",a_bc,a_b_c);
  return;
}

int main(void){
  run();
  return 0;
}
0