View Code of Problem 8

#include <iostream>
#include <cstring>
using namespace std;
int main(void){
	int n;
	char c[12]={0};
	cin>>n;
	while(n--){
		cin>>c;
		int len=strlen(c)-1;
		if(c[len]=='9'||c[len]=='1'||c[len]=='8')
			cout<<"294"<<endl;
		else if(c[len]=='3'||c[len]=='4'||c[len]=='5'||c[len]=='6'||c[len]=='7') 
			cout<<"293"<<endl;
		else if(c[len]=='0')
			cout<<"287"<<endl;
		else
			cout<<"286"<<endl;
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 8