結果

問題 No.752 mod数列
コンテスト
ユーザー %20
提出日時 2018-03-09 01:16:10
言語 C++17
(gcc 15.2.0 + boost 1.90.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
TLE  
実行時間 -
コード長 400 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,623 ms
コンパイル使用メモリ 208,452 KB
実行使用メモリ 11,392 KB
最終ジャッジ日時 2026-06-06 22:23:56
合計ジャッジ時間 9,833 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 3
other AC * 10 TLE * 1 -- * 20
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:7:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    7 | main(){
      | ^~~~

ソースコード

diff #
raw source code

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

ll s[50000000];

main(){
	ll P;
	scanf("%lld",&P);
	for(int i=1;i<=P;++i){
		s[i]=s[i-1]+P%i;
	}
	int Q;
	scanf("%d",&Q);
	for(int i=0;i<Q;++i){
		int L,R;
		scanf("%d%d",&L,&R);
		if(R<=P){
			printf("%lld\n",s[R]-s[L-1]);
		}else if(L<=P){
			printf("%lld\n",s[P]-s[L-1]+P*(R-P));
		}else{
			printf("%lld\n",P*(R-L+1));
		}
	}
}
0