結果

問題 No.403 2^2^2
ユーザー akakimidoriakakimidori
提出日時 2017-06-09 02:04:32
言語 C90
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 781 bytes
コンパイル時間 266 ms
コンパイル使用メモリ 22,096 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-23 19:56:42
合計ジャッジ時間 1,751 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 0 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 0 ms
4,348 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 0 ms
4,348 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 1 ms
4,348 KB
testcase_10 AC 1 ms
4,348 KB
testcase_11 AC 1 ms
4,348 KB
testcase_12 AC 1 ms
4,348 KB
testcase_13 AC 1 ms
4,348 KB
testcase_14 AC 0 ms
4,348 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 1 ms
4,348 KB
testcase_18 AC 1 ms
4,348 KB
testcase_19 AC 1 ms
4,348 KB
testcase_20 AC 1 ms
4,348 KB
testcase_21 AC 0 ms
4,348 KB
testcase_22 AC 1 ms
4,348 KB
testcase_23 AC 1 ms
4,348 KB
testcase_24 AC 0 ms
4,348 KB
testcase_25 WA -
testcase_26 AC 1 ms
4,348 KB
testcase_27 AC 0 ms
4,348 KB
testcase_28 AC 0 ms
4,348 KB
testcase_29 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘run’:
main.c:47:3: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   47 |   scanf("%lld^%lld^%lld",&a,&b,&c);
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include<stdio.h>

typedef long long int ln;

int phi(int n){
  int res=1;
  if(n%2==0){
    n/=2;
    while(n%2==0){
      res*=2;
      n/=2;
    }
  }
  int k=3;
  while(k*k<=n){
    if(n%k==0){
      res*=k-1;
      n/=k;
      while(n%k==0){
	res*=k;
	n/=k;
      }
    }
    k+=2;
  }
  if(n>1){
    res*=n-1;
  }
  return res;
}

int modPow(ln r,ln n,int mod){
  r=r%mod;
  n=n%phi(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 p=1000000007;

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

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