結果

問題 No.1327 グラフの数え上げ
ユーザー tko919tko919
提出日時 2020-12-24 11:17:33
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 202 ms / 2,000 ms
コード長 895 bytes
コンパイル時間 1,539 ms
コンパイル使用メモリ 167,728 KB
実行使用メモリ 19,880 KB
最終ジャッジ日時 2023-10-21 15:36:49
合計ジャッジ時間 2,913 ms
ジャッジサーバーID
(参考情報)
judge10 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 166 ms
4,348 KB
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 AC 1 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 55 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 1 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 23 ms
5,356 KB
testcase_16 AC 202 ms
19,880 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;

//template
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
template<typename T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
//end

const int mod=1000000007;
const int d=100000000;
int pre[]={
1,
927880474,
933245637,
668123525,
429277690,
733333339,
724464507,
957939114,
203191898,
586445753,
698611116};

int main(){
   string n; cin>>n;
   if(n.size()>10 or (n.size()==10&&n>"1000000007"))puts("0");
   else{
      ll m=stoi(n)-1,res=pre[m/d];
      rep(x,m/d*d+1,m+1)res=(1LL*res*x)%mod;
      if(m%2==1)res=(mod-res)%mod;
      cout<<res<<endl;
   }
   return 0;
}
0