結果
問題 | No.1260 たくさんの多項式 |
ユーザー | beet |
提出日時 | 2020-10-24 13:52:04 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 302 ms / 2,000 ms |
コード長 | 3,131 bytes |
コンパイル時間 | 2,334 ms |
コンパイル使用メモリ | 205,132 KB |
実行使用メモリ | 36,324 KB |
最終ジャッジ日時 | 2024-07-21 15:13:10 |
合計ジャッジ時間 | 12,845 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 5 ms
5,248 KB |
testcase_01 | AC | 5 ms
5,376 KB |
testcase_02 | AC | 5 ms
5,376 KB |
testcase_03 | AC | 3 ms
5,376 KB |
testcase_04 | AC | 4 ms
5,376 KB |
testcase_05 | AC | 5 ms
5,376 KB |
testcase_06 | AC | 4 ms
5,376 KB |
testcase_07 | AC | 5 ms
5,376 KB |
testcase_08 | AC | 5 ms
5,376 KB |
testcase_09 | AC | 4 ms
5,376 KB |
testcase_10 | AC | 5 ms
5,376 KB |
testcase_11 | AC | 4 ms
5,376 KB |
testcase_12 | AC | 4 ms
5,376 KB |
testcase_13 | AC | 6 ms
5,376 KB |
testcase_14 | AC | 5 ms
5,376 KB |
testcase_15 | AC | 5 ms
5,376 KB |
testcase_16 | AC | 3 ms
5,376 KB |
testcase_17 | AC | 5 ms
5,376 KB |
testcase_18 | AC | 6 ms
5,376 KB |
testcase_19 | AC | 5 ms
5,376 KB |
testcase_20 | AC | 294 ms
36,196 KB |
testcase_21 | AC | 90 ms
19,796 KB |
testcase_22 | AC | 259 ms
36,196 KB |
testcase_23 | AC | 216 ms
36,068 KB |
testcase_24 | AC | 219 ms
36,320 KB |
testcase_25 | AC | 176 ms
36,204 KB |
testcase_26 | AC | 208 ms
36,200 KB |
testcase_27 | AC | 171 ms
36,196 KB |
testcase_28 | AC | 287 ms
36,196 KB |
testcase_29 | AC | 218 ms
36,012 KB |
testcase_30 | AC | 137 ms
19,688 KB |
testcase_31 | AC | 218 ms
36,196 KB |
testcase_32 | AC | 218 ms
36,324 KB |
testcase_33 | AC | 179 ms
36,136 KB |
testcase_34 | AC | 278 ms
36,196 KB |
testcase_35 | AC | 129 ms
19,684 KB |
testcase_36 | AC | 117 ms
19,684 KB |
testcase_37 | AC | 221 ms
36,196 KB |
testcase_38 | AC | 237 ms
36,196 KB |
testcase_39 | AC | 279 ms
36,176 KB |
testcase_40 | AC | 217 ms
36,196 KB |
testcase_41 | AC | 269 ms
36,068 KB |
testcase_42 | AC | 200 ms
36,196 KB |
testcase_43 | AC | 274 ms
36,196 KB |
testcase_44 | AC | 186 ms
36,196 KB |
testcase_45 | AC | 177 ms
36,192 KB |
testcase_46 | AC | 158 ms
19,808 KB |
testcase_47 | AC | 200 ms
36,068 KB |
testcase_48 | AC | 45 ms
11,620 KB |
testcase_49 | AC | 150 ms
19,592 KB |
testcase_50 | AC | 80 ms
11,556 KB |
testcase_51 | AC | 279 ms
36,072 KB |
testcase_52 | AC | 101 ms
19,812 KB |
testcase_53 | AC | 133 ms
19,812 KB |
testcase_54 | AC | 287 ms
36,072 KB |
testcase_55 | AC | 297 ms
36,068 KB |
testcase_56 | AC | 141 ms
19,684 KB |
testcase_57 | AC | 205 ms
36,196 KB |
testcase_58 | AC | 126 ms
19,684 KB |
testcase_59 | AC | 216 ms
36,196 KB |
testcase_60 | AC | 302 ms
36,196 KB |
ソースコード
// verification-helper: PROBLEM https://yukicoder.me/problems/5011 #include<bits/stdc++.h> using namespace std; #define call_from_test #ifndef call_from_test #include <bits/stdc++.h> using namespace std; #endif //BEGIN CUT HERE // split [1, n] into ranges whose elements have same quotients template<typename T> decltype(auto) quotients(T n){ vector<pair<T, T>> vp; T m; for(m=1;m*m<=n;m++) vp.emplace_back(m,m); for(T i=m;i>=1;i--){ T l=n/(i+1)+1,r=n/i; if(l<=r and vp.back().second<l) vp.emplace_back(l,r); } return vp; } //END CUT HERE #ifndef call_from_test //INSERT ABOVE HERE signed main(){ return 0; } #endif #ifndef call_from_test #include <bits/stdc++.h> using namespace std; #endif //BEGIN CUT HERE template<typename T,T MOD = 1000000007> struct Mint{ static constexpr T mod = MOD; 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; } static Mint add_identity(){return Mint(0);} static Mint mul_identity(){return Mint(1);} 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-() const{return v?Mint(MOD-v):Mint(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;} static Mint comb(long long n,int k){ Mint num(1),dom(1); for(int i=0;i<k;i++){ num*=Mint(n-i); dom*=Mint(i+1); } return num/dom; } }; template<typename T,T MOD> constexpr T Mint<T, MOD>::mod; template<typename T,T MOD> ostream& operator<<(ostream &os,Mint<T, MOD> m){os<<m.v;return os;} //END CUT HERE #ifndef call_from_test //INSERT ABOVE HERE signed ABC127_E(){ cin.tie(0); ios::sync_with_stdio(0); int h,w,k; cin>>h>>w>>k; using M = Mint<int>; M ans{0}; for(int d=1;d<h;d++) ans+=M(d)*M(h-d)*M(w)*M(w); for(int d=1;d<w;d++) ans+=M(d)*M(w-d)*M(h)*M(h); ans*=M::comb(h*w-2,k-2); cout<<ans<<endl; return 0; } /* verified on 2019/06/12 https://atcoder.jp/contests/abc127/tasks/abc127_e */ signed main(){ //ABC127_E(); return 0; } #endif #undef call_from_test signed main(){ cin.tie(0); ios::sync_with_stdio(0); const char newl = '\n'; using ll = long long; ll n; cin>>n; using M = Mint<int>; M ans{0}; for(auto[l,r]:quotients(n)){ if(l==1) continue; ll d=n/l; if(d<l){ ans+=M(n)*M(r-l+1); ans-=M(d)*M(l-1+r-1)*M(r-l+1)/M(2); continue; } for(ll i=l;i<=r;i++) for(ll t=n;t;t/=i) ans+=M(t%i); } cout<<ans<<newl; return 0; }