結果

問題 No.793 うし数列 2
ユーザー sima.tettekesima.tetteke
提出日時 2019-09-22 03:22:56
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 728 bytes
コンパイル時間 2,816 ms
コンパイル使用メモリ 159,232 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-19 06:56:29
合計ジャッジ時間 3,751 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 WA -
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 1 ms
4,348 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 2 ms
4,348 KB
testcase_17 WA -
testcase_18 AC 2 ms
4,348 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

ll mod = 1e9 + 7;

ll fast_pow(ll a, ll n){
    if(n == 0) return 1;
    //べき数nが奇数, aを前にだして, a^n-1の気持ちに
    if(n % 2 == 1){
        return a * fast_pow(a, n - 1) % mod;
    }else{
        //べき数nが偶数のとき,べき数を半分にして, aをまとめる. べき数を半分にする
        return fast_pow(a * a % mod, n / 2) % mod;
    }
}

//等差数列の和 初項a 公比r 項数n
ll tousa_sum(ll a, ll r, ll n){
    ll sum = a * (fast_pow(r, n) - 1 ) / (r - 1);
    return sum;
}

int main(){

    ll N;
    cin >> N;
    
    ll ans = fast_pow(10, N) + tousa_sum(3, 10, N);

    cout << ans << endl;

} 
0