結果

問題 No.403 2^2^2
ユーザー KKT89
提出日時 2020-07-14 00:48:09
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 13 ms / 2,000 ms
コード長 772 bytes
コンパイル時間 932 ms
コンパイル使用メモリ 108,076 KB
最終ジャッジ日時 2025-01-11 20:23:27
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 27
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:32:20: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   32 |     ll a,b,c; scanf("%lld^%lld^%lld",&a,&b,&c);
      |               ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cstdio>
#include <ctime>
#include <assert.h>
#include <chrono>
#include <random>
#include <numeric>
#include <set>
using namespace std;
typedef long long int ll;
using ull = unsigned long long;

constexpr ll Mod=1e9+7;

ll mod_pow(ll a,ll b,ll mod){
    a%=mod;
    if(b==0)return 1;
    if(b==1)return a;
    ll res=mod_pow(a,b/2,mod)%mod;
    res*=res; res%=mod;
    if(b%2)res*=a;
    return res%mod;
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll a,b,c; scanf("%lld^%lld^%lld",&a,&b,&c);
    printf("%lld ",mod_pow(mod_pow(a,b,Mod),c,Mod));
    ll res=mod_pow(a,mod_pow(b,c,Mod-1),Mod);
    if(a%Mod==0)res=0;
    printf("%lld\n",res);
}
0