hdu2090
模拟
#include<stdio.h>
int main(){
char b[];
double price=,a1,a2;
int i=;
while(scanf("%s%lf%lf",b,&a1,&a2)!=EOF){
price+=a1*a2;
// printf("%.1lf\n",price);
}
printf("%.1lf\n",price);
return ;
}
hdu2091
模拟实现
#include<stdio.h> int main(){
char a;
int b;
int t=;
while(scanf("%c",&a)!=EOF&&a!='@'){
scanf("%d%*c",&b);
if(t++)printf("\n");
int i;
if(b==){
printf("%c\n",a);
continue;
}
for(i=;i<=b-;i++)printf(" ");
printf("%c\n",a);
if(b>=){
for(i=;i<=b-;i++){
for(int j=;j<=b-i;j++) printf(" ");
printf ("%c",a);
for(int j=;j<=*(i-)-;j++) printf(" ");
printf ("%c\n",a);
}
}
for(i=;i<=*b-;i++)printf("%c",a);
printf("\n");
}
return ;
}
hdu2092
暴力模拟
#include<stdio.h>
#include<math.h> int main(){
int m,n;
while(scanf("%d%d",&n,&m)!=EOF&&(n!=||m!=)){
double d=n*n-*m;
if(d<){
printf("No\n");
continue;
}
else{
double l1=n/2.0+sqrt(d)/2.0,l2=n/2.0-sqrt(d)/2.0;
int t1=l1,t2=l2;
if(fabs(t1-l1)<1e-&&fabs(t2-l2)<1e-)printf("Yes\n");
else printf("No\n");
}
}
return ;
}
hdu2093
麻烦一点的模拟
#include<stdio.h>
#include<string.h>
struct list{
char name[];
int am;
int pt;
}l[];
void ex(int i,int j){
char temp[];int t;
{
strcpy(temp,l[i].name);
strcpy(l[i].name,l[j].name);
strcpy(l[j].name,temp);
}
{
t=l[i].am;
l[i].am=l[j].am;
l[j].am=t;
}
{
t=l[i].pt;
l[i].pt=l[j].pt;
l[j].pt=t;
}
}
int main(){
int p[];
int n,m;
while(scanf("%d%d",&n,&m)!=EOF){
for(int q=;q<=;q++){
l[q].am=l[q].pt=;
scanf("%s",l[q].name);
for(int k=;k<=n;k++){
int a;
scanf("%d",&a);
if(a>){
l[q].am++;
l[q].pt+=a;
}
char b=getchar();
if(b=='('){
scanf("%d",&a);
l[q].pt+=m*a;
getchar();
}
} }
int i,j;
for(i=;i<=;i++){
for(j=i+;j<=;j++){
if(l[i].am<l[j].am){
ex(i,j);
}
else if(l[i].am==l[j].am&&l[i].pt>l[j].pt){
ex(i,j);
}
else if(l[i].am==l[j].am&&l[i].pt==l[j].pt&&strcmp(l[i].name,l[j].name)>){
ex(i,j);
}
}
}
for(i=;i<=;i++){
printf("%-10s %2d %4d\n",l[i].name,l[i].am,l[i].pt);
}
}
return ;
}
hdu2094
有胜负关系,判断是否能够决出冠军(唯一不败),map记录某个人是否失败过
#include<stdio.h>
#include<string.h>
#include<map>
#include<string>
#include<iostream>
using namespace std; int main(){
int n;
while(scanf("%d",&n)!=EOF&&n){
map<string,int>m;
int ans=;
while(n--){
string a,b;
cin>>a>>b;
if(m[a]==){
ans++;
m[a]=-;
}
if(m[b]==)m[b]++;
else if(m[b]==-){
m[b]=;
ans--;
}
}
if(ans==)printf("Yes\n");
else printf("No\n");
}
return ;
}
hdu2095
找唯一一个只出现一次的数,将所有数异或,最后得到的就是出现一次的数
#include<stdio.h>
int main(){
int n;
while(scanf("%d",&n)!=EOF&&n!=){
int a=,b;
for(int q=;q<=n;q++){
scanf("%d",&b);
a^=b;
}
printf("%d\n",a);
}
return ;
}
hdu2096
最后两位的A+B,模拟
#include<stdio.h>
int main(){
int T;
while(scanf("%d",&T)!=EOF){
for(int q=;q<=T;q++){
int a,b;
scanf("%d%d",&a,&b);
a%=;
b%=;
int ans=(a+b)%;
printf("%d\n",ans);
} }
return ;
}
hdu2097
模拟
#include<stdio.h> int main(){
int n;
while(scanf("%d",&n)!=EOF&&n!=){
int ans10=,ans12=,ans16=;
int t=n;
while(t){
ans10+=t%;
t/=;
}
t=n;
while(t){
ans16+=t%;
t/=;
}
t=n;
while(t){
ans12+=t%;
t/=;
}
if(ans10==ans12&&ans12==ans16)printf("%d is a Sky Number.\n",n);
else printf("%d is not a Sky Number.\n",n);
}
return ;
}