A
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main()
{
int t;
scanf("%d",&t);
while(t--){
int n;
int sum = 0;
int a,b;
scanf("%d",&n);
for(int i=0;i<n;++i){
scanf("%d%d",&a,&b);
sum+=a*b;
}
printf("%d\n",sum);
}
return 0;
}
B
模拟一下
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
int s[7][5];
int t[7][5];
bool check(){
int f =1;
for(int i= 1;i<=6;++i){
if(!(t[i][1]==t[i][2] && t[i][2]==t[i][3] && t[i][3]==t[i][4])){
f = 0;
break;
}
}
if(f) return true;
else return false;
}
int main()
{
int tt;
scanf("%d",&tt);
while(tt--){
for(int i = 1;i<=6;++i){
for(int j = 1;j<=4;++j)
scanf("%d",&s[i][j]);
}
///复原
for(int i = 1;i<=6;++i){
for(int j = 1;j<=4;++j)
t[i][j] = s[i][j];
}
if(check()){
printf("YES\n");
continue;
}
///上面的左转
t[2][1] = s[6][3];
t[2][2] = s[6][1];
t[5][2] = s[2][1];
t[5][4] = s[2][2];
t[4][4] = s[5][2];
t[4][3] = s[5][4];
t[6][3] = s[4][4];
t[6][1] = s[4][3];
if(check()){
printf("YES\n");
continue;
}
///上面的右转
t[2][2] = s[5][4];
t[2][1] = s[5][2];
t[5][4] = s[4][3];
t[5][2] = s[4][4];
t[4][3] = s[6][1];
t[4][4] = s[6][3];
t[6][1] = s[2][2];
t[6][3] = s[2][1];
if(check()){
printf("YES\n");
continue;
}
///复原
for(int i = 1;i<=6;++i){
for(int j = 1;j<=4;++j)
t[i][j] = s[i][j];
}
///右边的上转
t[1][2] = s[2][2];
t[1][4] = s[2][4];
t[2][2] = s[3][2];
t[2][4] = s[3][4];
t[3][2] = s[4][2];
t[3][4] = s[4][4];
t[4][2] = s[1][2];
t[4][4] = s[1][4];
if(check()){
printf("YES\n");
continue;
}
///右边下转
t[2][2] = s[1][2];
t[2][4] = s[1][4];
t[1][2] = s[4][2];
t[1][4] = s[4][4];
t[4][2] = s[3][2];
t[4][4] = s[3][4];
t[3][2] = s[2][2];
t[3][4] = s[2][4];
if(check()){
printf("YES\n");
continue;
}
///复原
for(int i = 1;i<=6;++i){
for(int j = 1;j<=4;++j)
t[i][j] = s[i][j];
}
///前面左传
t[1][3] = s[6][3];
t[1][4] = s[6][4];
t[6][3] = s[3][2];
t[6][4] = s[3][1];
t[3][2] = s[5][3];
t[3][1] = s[5][4];
t[5][3] = s[1][3];
t[5][4] = s[1][4];
if(check()){
printf("YES\n");
continue;
}
///前面右传
t[1][3] = s[5][3];
t[1][4] = s[5][4];
t[6][3] = s[1][3];
t[6][4] = s[1][4];
t[3][2] = s[6][3];
t[3][1] = s[6][4];
t[5][3] = s[3][2];
t[5][4] = s[3][1];
if(check()){
printf("YES\n");
continue;
}
printf("NO\n");
}
return 0;
}
C
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
int main()
{
int t;
scanf("%d",&t);
while(t--){
double a=0,b=0;
scanf("%lf%lf",&a,&b);
if(a<=b)
printf("0.000000\n");
else{
printf("%.6I64f\n",log(a/b)+1);
}
}
return 0;
}