結果

問題 No.1275 綺麗な式
ユーザー kyoprounokyoprouno
提出日時 2020-10-30 23:15:15
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,420 bytes
コンパイル時間 2,559 ms
コンパイル使用メモリ 172,736 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-29 08:21:00
合計ジャッジ時間 4,375 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 2 ms
4,380 KB
testcase_31 AC 1 ms
4,376 KB
testcase_32 WA -
testcase_33 AC 1 ms
4,376 KB
testcase_34 WA -
testcase_35 AC 2 ms
4,380 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 AC 1 ms
4,380 KB
testcase_41 WA -
testcase_42 AC 1 ms
4,376 KB
testcase_43 AC 2 ms
4,376 KB
testcase_44 WA -
testcase_45 WA -
testcase_46 AC 2 ms
4,380 KB
testcase_47 AC 2 ms
4,376 KB
testcase_48 AC 1 ms
4,376 KB
testcase_49 AC 2 ms
4,376 KB
testcase_50 AC 1 ms
4,376 KB
testcase_51 AC 1 ms
4,376 KB
testcase_52 WA -
testcase_53 WA -
testcase_54 WA -
testcase_55 WA -
testcase_56 WA -
testcase_57 WA -
testcase_58 WA -
testcase_59 WA -
testcase_60 WA -
testcase_61 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC optimize("O3")
#include <algorithm>

#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define endl '\n'
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;



template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}

const int INF=1e9;

const ll mod = 1e9+7;

long double pow_d(long double val,ll t){
    if (!t) return 1.0;
    long double a = pow_d(val,t>>1);
    a *= a;
    ll num=a;
    if(num>mod){
        ll k=num/mod;
        long double ab=k;
        long double m=mod;
        a-=ab*m;
    }
    if (t&1) a *=val;
    num=a;
    if(num>mod){
        ll k=num/mod;
        long double ab=k;
        long double m=mod;
        a-=ab*m;
    }
    return a;
}

int main(){
    ll a,b,n;
    cin >> a >> b >> n;
    long double A=a,B=b;
    long double c=A+sqrt(B),d=A-sqrt(B);
    long double m=mod;
    if(d<0) d+=m;
    long double p=pow_d(c,n),q=pow_d(d,n);
    long double ans=p+q;
    ll v=round(ans);
    v%=mod;
    cout << v << endl;
    return 0;
}
0