Time Limit: 2 sec / Memory Limit: 1024 MB
Score : 200200 points
Problem Statement
There are N people numbered 1 to N.
Person ii guessed the building area of KEYENCE headquarters building to be Si square meters.
The shape of KEYENCE headquarters building is shown below, where aa and bb are some positive integers.
That is, the building area of the building can be represented as 4ab+3a+3b4ab+3a+3b.
Based on just this information, how many of the N people are guaranteed to be wrong in their guesses?
Constraints
- 1≤N≤20
- 1≤Si≤1000
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
N
S1… Sn
Output
Print the answer.
Sample Input 1
3
10 20 39
Sample Output 1
1
The area would be 1010 square meters if a=1,b=1a=1,b=1, and 39 square meters if a=2,b=3a=2,b=3.
However, no pair of positive integers aa and bb would make the area 20 square meters.
Thus, we can only be sure that Person 2 guessed wrong.
Sample Input 2
5
666 777 888 777 666
Sample Output 2
3
此题只需暴力模拟。
代码:
#include <iostream>
using namespace std;
#define sum 4 * a * b + 3 * a + 3 * b
int main(){
int n;
int s[99];
cin >> n;
for(int i = 1;i <= n;i++) cin >> s[i];
int ans = 0;
for(int i = 1;i <= n;i++){
bool t = false ;
for(int a = 1;a <= 1000;a++)
for(int b = 1;b <= 1000;b++)
if( sum == s[i]) t = true;
if(t == false ) ans++;
}
cout << ans << endl ;
return 0;
}