#include<iostream>constdouble pi =3.14;usingnamespace std;intmain(){int n;
cin >> n;double r;double** cnt =newdouble*[n +1];for(int i =1; i <= n; i++){
cnt[i]=newdouble[2];
cin >> cnt[i][0]>> cnt[i][1];
r = cnt[i][0]* cnt[i][0]+ cnt[i][1]* cnt[i][1];for(int k =0;; k++){if(r <(100.0* k)/ pi){printf("Property %d: This property will begin eroding in year %d.\n", i, k);break;}}}
cout <<"END OF OUTPUT.";}
1075
#include<iostream>usingnamespace std;// 注意减枝classSolution{public:voidinit()// 初始化{char str[5];int a =0;for(int i =0; i <4; i++){
cin >> str;for(int k =0; k <4; k++){
cnt[a++]= str[k]=='b'?0:1;}}
min =20;
number =0;}intcheck(){// 检查是否全部同色for(int i =1; i <16; i++){if(cnt[0]!= cnt[i])return0;}return1;}voidflip(int i){// 进行翻转int x = i /4;int y = i %4;
cnt[i]=!cnt[i];if(x >0) cnt[i -4]=!cnt[i -4];if(x <3) cnt[i +4]=!cnt[i +4];if(y >0) cnt[i -1]=!cnt[i -1];if(y <3) cnt[i +1]=!cnt[i +1];}voidfun(int i){// i表示处理到第几个棋子的下标if(i >=16){if(check())// 最后的时候才检查
min = min < number ? min : number;return;// 函数的出口}else{fun(i +1);// 优先进行不翻转
number++;int flag =0;if(number < min){flip(i);
flag =1;fun(i +1);}if(flag){flip(i);}
number--;}}voidout_print(){if(min ==20) cout <<"Impossible"<< endl;else cout << min << endl;}private:int cnt[16];int min;// poj 不允许在类中初始化,在init 中初始化int number;};intmain(){
Solution answer;
answer.init();
answer.fun(0);
answer.out_print();return0;}
3259
#include<iostream>#include<cstring>#include<cassert>usingnamespace std;classSolution{private:
string s;int cur;char a[5];voidChange(char i){for(int j =0; j !=5; j++)
a[j]=((i >> j)&00000001);}boolCal(){char c = s[cur];bool w, x;
cur++;switch(c){case'p':return a[0];case'q':return a[1];case'r':return a[2];case's':return a[3];case't':return a[4];case'N':return!Cal();case'K':
w =Cal();
x =Cal();return(w && x);case'A':
w =Cal();
x =Cal();return(w || x);case'C':
w =Cal();
x =Cal();return(w <= x);case'E':
w =Cal();
x =Cal();return(w == x);default:return0;}}public:voidevaluateExpressions(){int f;while(1){
cin >> s;if(s =="0")break;
f =1;for(char i =0; i !=32; i++){
cur =0;Change(i);if(!Cal()){
f =0;break;}}if(f ==1)
cout <<"tautology"<< endl;else
cout <<"not"<< endl;}}};intmain(){
Solution solution;
solution.evaluateExpressions();return0;}