[ABC429]A - Too Many Requests 题解
Time Limit: 2 sec / Memory Limit: 1024 MiB
时间限制:2 秒 / 内存限制:1024MiB
Score : 100 points 分数: 100 分
Problem Statement 题目描述
You are given positive integers N and M.
给定正整数 N 和 M 。
Print N lines. 打印第 0#行。
The i-th line (1≤i≤N) should contain OK if i≤M, and Too Many Requests otherwise.
第 i 行应包含 OK ,如果 i≤M ,否则包含 Too Many Requests 。
Constraints 约束条件
- 1≤N≤10
- 1≤M≤10
- N and M are integers.
N 和 M 是整数。
Input 输入
The input is given from Standard Input in the following format:
标准输入中给出的输入格式如下:
N M
Output 输出
Print N lines according to the instructions in the problem statement.
根据题目要求打印 N 行。
Sample Input 1 示例输入 1 复制
5 3
Sample Output 1 样本输出 1 复制
OK
OK
OK
Too Many Requests
Too Many Requests
Since N=5 and M=3,
由于 N=5 和 M=3 ,
print OK on the 1st, 2nd, and 3rd lines,
在第 0#行、第 1#行和第 2#行打印 OK ,
and print Too Many Requests on the 4th and 5th lines.
并在第 0#行和第 1#行打印 Too Many Requests 。
Sample Input 2 示例输入 2 复制
3 5
Sample Output 2 样例输出 2 复制
OK
OK
OK
Since N=3 and M=5, print OK on the 1st, 2nd, and 3rd lines.
自 N=3 和 M=5 以来,在第 1 行、第 2 行和第 3 行打印 OK 。
思路
直接暴力输出即可。
代码见下
#include<bits/stdc++.h>
using namespace std;
long long n,m;
int main(){
cin>>n>>m;
for(int i=1;i<=n;i++){
if(i<=m){
cout<<"OK"<<endl;
}
else{
cout<<"Too Many Requests"<<endl;
}
}
return 0;
}

浙公网安备 33010602011771号