結果
問題 |
No.644 G L C C D M
|
ユーザー |
![]() |
提出日時 | 2018-02-02 21:58:06 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,134 bytes |
コンパイル時間 | 963 ms |
コンパイル使用メモリ | 113,316 KB |
最終ジャッジ日時 | 2025-01-05 08:06:24 |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 12 WA * 15 |
ソースコード
#include <algorithm> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <ctime> #include <iostream> #include <sstream> #include <functional> #include <map> #include <set> #include <unordered_map> #include <unordered_set> #include <bitset> #include <string> #include <cstring> #include <vector> #include <queue> #include <stack> #include <deque> #include <list> #include <numeric> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long double ld; typedef pair<ll,ll> P; typedef pair<P,ll> PPI; typedef pair<ll,P> PIP; typedef vector<ll> vl; typedef vector<vl> vvl; typedef vector<P> vp; #define PQ(T) priority_queue<T,vector<T>,greater<T>> #define PQ2(T) priority_queue<T> const double PI = 3.14159265358979323846; const double EPS = 1e-12; const ll INF = 1LL<<29; const ll mod = 1e9+7; #define REP(i,a,b) for(ll (i)=a;(i)<(ll)(b);++(i)) #define rep(i,n) REP(i,0,n) #define rep1(i,n) REP(i,1,n+1) #define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d)) #define all(v) (v).begin(), (v).end() #define pb(x) push_back(x) #define mp(x,y) make_pair((x),(y)) #define mset(m,v) memset((m),(v),sizeof(m)) #define chmin(x,y) ((x)=min((x),(y))) #define chmax(x,y) ((x)=max((x),(y))) #define fst first #define snd second #define UNIQUE(x) (x).erase(unique(all(x)),(x).end()) #define DEBUG(x) cerr<<"line ("<<__LINE__<<") "<<#x<<": "<<x<<endl; template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;} #define N 110000 ll fact[N]; bool isPrime(ll x){ if(x<=1) return false; for(ll i = 2; i*i<=x; i++) if(x%i==0) return false; return true; } int main(){ ll n, m; cin>>n>>m; fact[0] = 1; rep(i, n) fact[i+1] = fact[i]*(i+1)%mod; ll res = 0; /*for(ll i = m; i <= n; i+=m){ ll n2 = n/m, i2 = i/m; //cerr<<n2<<" "<<i2<<" "<<(n2-n2/i2)<<endl; ll t = n2-n2/i2; if(i2==1) t = n2-1; (res+=t*fact[n-2])%=mod; }*/ ll n2 = n/m; ll cnt = 0; for(ll i = 1; i <= n2; i++){ if(isPrime(i)) cnt += n2/i; } cerr<<n2*n2-cnt<<endl; res = (n2*n2-cnt-1)%mod*fact[n-2]%mod; cout<<res<<endl; return 0; }