結果

問題 No.741 AscNumber(Easy)
ユーザー greentea011greentea011
提出日時 2018-10-09 14:45:18
言語 C++11
(gcc 13.3.0)
結果
AC  
実行時間 7 ms / 2,000 ms
コード長 525 bytes
コンパイル時間 591 ms
コンパイル使用メモリ 54,108 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-12 16:31:06
合計ジャッジ時間 2,036 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 55
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:28:15: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 2 has type ‘long long int’ [-Wformat=]
   28 |     printf("%ld\n", c*modinv(p,1000000007)%1000000007);
      |             ~~^     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |               |                           |
      |               long int                    long long int
      |             %lld
main.cpp:21:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   21 |     scanf("%ld",&n);
      |     ~~~~~^~~~~~~~~~

ソースコード

diff #

#include <stdio.h>
#include <iostream>

long long modinv(long long a,long long m) {
    long long b=m,u=1,v=0;
    long long t;
    while(b) {
        t=a/b;
        a-=t*b;
        std::swap(a,b);
        u-=t*v;
        std::swap(u,v);
    }
    u%=m;
    if(u<0)u+=m;
    return u;
}

int main() {
    long n;
    scanf("%ld",&n);
    long c=1;
    long p=1;
    for (int i=n;i!=0;i--) {
        c=c*(9+i)%1000000007;
        p=p*i%1000000007;
    }
    printf("%ld\n", c*modinv(p,1000000007)%1000000007);
    return 0;
}
0