結果

問題 No.41 貯金箱の溜息(EASY)
ユーザー beetbeet
提出日時 2018-11-27 21:01:57
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 22 ms / 5,000 ms
コード長 1,630 bytes
コンパイル時間 2,124 ms
コンパイル使用メモリ 199,660 KB
実行使用メモリ 6,088 KB
最終ジャッジ日時 2023-09-06 13:18:58
合計ジャッジ時間 2,487 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 22 ms
6,084 KB
testcase_01 AC 22 ms
6,088 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


template<typename T,T MOD = 1000000007>
struct Mint{
  T v;
  Mint():v(0){}
  Mint(signed v):v(v){}
  Mint(long long t){v=t%MOD;if(v<0) v+=MOD;}

  Mint pow(long long k){
    Mint res(1),tmp(v);
    while(k){
      if(k&1) res*=tmp;
      tmp*=tmp;
      k>>=1;
    }
    return res;
  }
  
  Mint inv(){return pow(MOD-2);}
  
  Mint& operator+=(Mint a){v+=a.v;if(v>=MOD)v-=MOD;return *this;}
  Mint& operator-=(Mint a){v+=MOD-a.v;if(v>=MOD)v-=MOD;return *this;}
  Mint& operator*=(Mint a){v=1LL*v*a.v%MOD;return *this;}
  Mint& operator/=(Mint a){return (*this)*=a.inv();}
  
  Mint operator+(Mint a) const{return Mint(v)+=a;};
  Mint operator-(Mint a) const{return Mint(v)-=a;};
  Mint operator*(Mint a) const{return Mint(v)*=a;};
  Mint operator/(Mint a) const{return Mint(v)/=a;};

  Mint operator-(){return v?MOD-v:v;}

  bool operator==(const Mint a)const{return v==a.v;}
  bool operator!=(const Mint a)const{return v!=a.v;}
  bool operator <(const Mint a)const{return v <a.v;}

};
//INSERT ABOVE HERE
signed main(){
  using M = Mint<Int, Int(1e9+9)>;
  const Int MAX = 2e5;
  vector<M> dp(MAX);
  dp[0]=1;
  for(Int x=1;x<10;x++)
    for(Int i=0;i+x<MAX;i++)
      dp[i+x]+=dp[i];
  
  vector<M> sm(MAX);
  for(Int i=0;i<MAX;i++){
    sm[i]=dp[i];
    if(i) sm[i]+=sm[i-1];
  }
  Int t;
  cin>>t;
  while(t--){
    Int m;
    cin>>m;
    Int x=m/111111;
    cout<<sm[x].v<<endl;
  }
  return 0;
}
0