Codeforces Round 993A Easy Problem
https://codeforces.com/contest/2044/problem/A
修改地址2044就可以了。
思路很简单,每次-1
#include <iostream>
#include <string>
#include <vector>
using namespace std;int main()
{int t = 0,n=0,c1=0;cin >> t;int a = 0, b = 0;while (t--){cin >> n;c1 = 0;for (int i = n-1; i >0; i--){a = i - 1;b = n - a;c1++;}cout << c1 << endl;c1 = 0;}return 0;
}/*
Cube is given an integer N.
She wants to know how many ordered pairs of positive integers(a,b),
there are such that a=n-b.
Since Cube is not very good at math,
please help her!Input
The first line contains an integer t(1≤t≤99) — the number of test cases.The only line of each test case contains an integer n(2≤n≤100).Output
For each test case, output the number of ordered pairs (a,b)
on a new line.Example
Input
3
2
4
6
Output
1
3
5
*/
第二种方法,也是可以,都是AC
#include <iostream>
#include <string>
#include <vector>
using namespace std;int main()
{int t = 0,n=0;cin >> t;int a = 0, b = 0;while (t--){cin >> n;cout << n - 1<<endl;}return 0;
}