結果

問題 No.1276 3枚のカード
ユーザー 👑 kmjpkmjp
提出日時 2020-10-30 23:07:49
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,841 bytes
コンパイル時間 2,070 ms
コンパイル使用メモリ 208,708 KB
実行使用メモリ 9,624 KB
最終ジャッジ日時 2023-09-29 08:11:49
合計ジャッジ時間 57,715 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 TLE -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 172 ms
4,424 KB
testcase_15 WA -
testcase_16 TLE -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 TLE -
testcase_23 AC 151 ms
4,376 KB
testcase_24 WA -
testcase_25 AC 754 ms
6,244 KB
testcase_26 TLE -
testcase_27 TLE -
testcase_28 TLE -
testcase_29 WA -
testcase_30 AC 327 ms
4,964 KB
testcase_31 AC 139 ms
4,404 KB
testcase_32 AC 813 ms
6,252 KB
testcase_33 AC 42 ms
4,376 KB
testcase_34 AC 547 ms
5,680 KB
testcase_35 AC 517 ms
5,556 KB
testcase_36 AC 27 ms
4,376 KB
testcase_37 AC 476 ms
5,608 KB
testcase_38 AC 310 ms
4,928 KB
testcase_39 AC 852 ms
6,356 KB
testcase_40 TLE -
testcase_41 TLE -
testcase_42 TLE -
testcase_43 TLE -
testcase_44 TLE -
testcase_45 TLE -
testcase_46 TLE -
testcase_47 TLE -
testcase_48 TLE -
testcase_49 TLE -
testcase_50 TLE -
testcase_51 TLE -
testcase_52 WA -
testcase_53 TLE -
testcase_54 TLE -
testcase_55 TLE -
testcase_56 WA -
testcase_57 TLE -
testcase_58 TLE -
testcase_59 TLE -
testcase_60 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define FORR2(x,y,arr) for(auto& [x,y]:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
const ll mo=1000000007;

ll slow(int v) {
	ll ret=0;
	int i;
	for(i=2;i<=v;i++) {
		ll p=v/i;
		if(p<1) break;
		ret+=p-1;
	}
	return ret%mo;
}

ll hoge(int v) {
	if(v<=100) return slow(v);
	ll ret=0;
	int sq=sqrt(v)+2;
	map<int,int> M; // M[x]= |N/i|がxになる数
	int i;
	for(i=2;i<=sq;i++) M[v/i]++;
	for(i=1;i<=sq;i++) {
		int L=v/i;
		int R=max(sq+1,v/(i+1)+1);
		if(L>=R) M[i]+=L-R+1;
	}
	FORR(m,M) ret+=1LL*(m.first-1)*m.second%mo;
	return ret%mo;
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	//for(i=1;i<=20;i++) cout<<hoge(i)<<endl;
	
	cin>>N;
	ll ret=0;
	map<int,int> M; // M[x]= |N/i|がxになる数
	for(i=1;i<=min(20000,N);i++) M[N/i]++;
	for(i=1;i<=20000;i++) {
		int L=N/i;
		int R=max(20001,N/(i+1)+1);
		if(L>=R) M[i]+=L-R+1;
	}
	
	
	// ? x aX
	FORR(m,M) {
		//cout<<m.first<<" "<<m.second<<endl;
		ll b=m.first-1;
		// ? x bx (b>1)
		(ret+=(N-2)*b%mo*m.second)%=mo;
		// ax x bx (a>=1, b>1, a!=b)を引く
		ll a=(m.first-2);
		(ret-=a*b%mo*m.second)%=mo;
	}
	// X aX abX (1<a<b)
	FORR(m,M) {
		ll pat=hoge(m.first);
		(ret-=pat*m.second)%=mo;
	}
	ret=(ret%mo+mo)%mo;
	
	cout<<ret<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}
0