A.11-1
Sample Input
50 10
Sample Output
8
思路:循环,一个等差一个等比,没什么好说的
//
// Created by haofeng on 4/29/20.
//
#include <iostream>
#include <algorithm>
using namespace std;
double K;
double N;
double Eps=0.001;
int main(){
cin>>N>>K;
double totalN=N;
double totalK=200;
int year=0;
for (int i = 1; i <= 20; ++i) {
//cout<<totalN<< " "<<totalK<<endl;
if(abs(totalN-totalK)<Eps||totalN>totalK){
year=i;
break;
}
totalN+=N;
totalK*=(1+K/100);
}
if(year==0){
cout<<"Impossible";
}
else{
cout<<year;
}
}
B.11-2
Sample Input
4
0 0 0 0
0 0 0 0
0 1 0 0
0 0 0 0
0 0 0 0
0 1 0 0
0 0 0 0
0 0 0 0
Sample Output
1
思路:把顺时针的过程描述出来即可,因为要来回转注意储存问题
//
// Created by haofeng on 4/29/20.
//
#include <iostream>
using namespace std;
int n;
int N[20][20];
int M[20][20];
int HOPE[20][20];
bool same(int m0n){
if(m0n==0) {
//用n判断
for (int i = 0; i < n; ++i) {
for (int j = 0; j < n; ++j) {
if (N[i][j] != HOPE[i][j]) {
return false;
}
}
}
} else{
//用m判断
for (int i = 0; i < n; ++i) {
for (int j = 0; j < n; ++j) {
if (M[i][j] != HOPE[i][j]) {
return false;
}
}
}
}
return true;
}
void turn(int n2m){
if