結果
| 問題 |
No.752 mod数列
|
| コンテスト | |
| ユーザー |
%20
|
| 提出日時 | 2018-03-09 01:16:10 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 400 bytes |
| コンパイル時間 | 2,382 ms |
| コンパイル使用メモリ | 192,044 KB |
| 最終ジャッジ日時 | 2025-01-05 09:08:17 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 TLE * 1 |
| other | AC * 17 TLE * 14 |
コンパイルメッセージ
main.cpp:7:1: warning: ISO C++ forbids declaration of ‘main’ with no type [-Wreturn-type]
7 | main(){
| ^~~~
main.cpp: In function ‘int main()’:
main.cpp:9:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
9 | scanf("%lld",&P);
| ~~~~~^~~~~~~~~~~
main.cpp:14:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
14 | scanf("%d",&Q);
| ~~~~~^~~~~~~~~
main.cpp:17:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
17 | scanf("%d%d",&L,&R);
| ~~~~~^~~~~~~~~~~~~~
ソースコード
#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));
}
}
}
%20