1559A - Mocha and Math
#include<stdio.h>
int main(){
int n,k,arr[100],t;
scanf("%d",&n);
while(n--){
scanf("%d",&k);
scanf("%d",&arr[0]);
t=arr[0];
for(int i=1;i<k;i++){
scanf("%d",&arr[i]);
t=t&arr[i];
}
printf("%d\n",t);
}
return 0;
}
每个case可以无数次位操作,那么穷尽所有可进行的位运算后,数列中的每一个数都是一样的大小,且是原数列所有数一起做&运算的结果 每做一次&运算,只可能变小或不变,不可能变大,所有穷尽运算必然最小
112A
#include<stdio.h>
#include<string.h>
int main(){
int s1=0,s2=0,n;
char a[100],b[100];
scanf("%s",a);
scanf("%s",b);
n=strlen(a);
for(int i=0;i<n;i++){
int kk=(int)a[i] ;
if(kk>95){
s1+=kk-96;
}
else{
s1+=kk-64;
}
kk=(int)b[i];
if(kk>95){
s2+=kk-96;
}
else{
s2+=kk-64;
}
}
if(s1<=s2){
if(s1==s2){
printf("%d\n",0);
}
else{
printf("%d\n",-1);
}
}
else{
printf("%d\n",1);
}
return 0;
}
第五个测试点出错 测试点: Test: #5, time: 0 ms., memory: 3612 KB, exit code: 0, checker exit code: 1, verdict: WRONG_ANSWER Input aslkjlkasdd asdlkjdajwi Output 0 Answer 1 Checker Log wrong answer expected 1, found 0
200B B. Drinks
Little Vasya loves orange juice very much. That’s why any food and drink in his kitchen necessarily contains orange juice. There are n drinks in his fridge, the volume fraction of orange juice in the i-th drink equals pi percent.
One day Vasya decided to make himself an orange cocktail. He took equal proportions of each of the n drinks and mixed them. Then he wondered, how much orange juice the cocktail has.
Find the volume fraction of orange juice in the final drink.
Input The first input line contains a single integer n (1?≤?n?≤?100) — the number of orange-containing drinks in Vasya’s fridge. The second line contains n integers pi (0?≤?pi?≤?100) — the volume fraction of orange juice in the i-th drink, in percent. The numbers are separated by a space.
Output Print the volume fraction in percent of orange juice in Vasya’s cocktail. The answer will be considered correct if the absolute or relative error does not exceed 10??-?4.
Examples input: 3 50 50 100 output: 66.666666666667
#include<stdio.h>
int main(){
int n,sum,t;
scanf("%d",&n);
for(int i=0;i<n;i++){
scanf("%d",&t);
sum+=t;
}
printf("%f",(double)sum/(double)n);
return 0;
}
原来进行输出采用的占字符时%lf,发现一直输出为0.000, 百度发现,%lf是double专属,%f是double、float混用的,并且c11不提供隐式类型转换,都要手动555555555555
|