結果

問題 No.554 recurrence formula
ユーザー notetonousnotetonous
提出日時 2017-08-12 00:18:09
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 701 bytes
コンパイル時間 497 ms
コンパイル使用メモリ 54,748 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-21 00:13:19
合計ジャッジ時間 1,099 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
5,248 KB
testcase_02 AC 3 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 3 ms
5,376 KB
testcase_05 AC 3 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 3 ms
5,376 KB
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 -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdio>
using namespace std;
long long int N;
long long int a[100001],b[100001];
long long int ans;
long long int mod=1000000007;
void add(long long int *bit,int i,long long int x){
  while(i<=N){
    (bit[i]+=x)%=mod;
    i+=i&-i;
  }
}
long long int sum(long long int *bit ,int i){
  long long int s=0;
  while(i>0){
    (s+=bit[i])%=mod;;
    i -=i& -i;
  }
  return  s;
}
int main(){
  for(int i=0;i<100001;i++){a[i]=0;b[i]=0;}
  cin >> N;
  add(a,1,1);
 
  for(int i=2;i<=N;i++){
    if(i%2==0){
      ans=i*sum(a,i/2);
      add(b,i/2,ans);
    }
    else{
      ans=i*sum(b,i/2);
      add(a,i/2+1,ans);
    }
    if(i==N)cout << ans << endl;
  }
 

  return 0;
}
0