zoukankan      html  css  js  c++  java
  • hdu2090-2097

    hdu2090

    模拟

     1 #include<stdio.h>
     2 int main(){
     3     char b[100];
     4     double price=0,a1,a2;
     5     int i=0;
     6     while(scanf("%s%lf%lf",b,&a1,&a2)!=EOF){
     7         price+=a1*a2;
     8     //    printf("%.1lf
    ",price);
     9     }
    10     printf("%.1lf
    ",price);
    11     return 0;
    12 }
    View Code

    hdu2091

    模拟实现

     1 #include<stdio.h>
     2 
     3 int main(){
     4     char a;
     5     int b;
     6     int t=0;
     7     while(scanf("%c",&a)!=EOF&&a!='@'){
     8         scanf("%d%*c",&b);
     9         if(t++)printf("
    ");
    10         int i;
    11         if(b==1){
    12             printf("%c
    ",a);
    13             continue;
    14         }
    15         for(i=1;i<=b-1;i++)printf(" ");
    16         printf("%c
    ",a);
    17         if(b>=3){
    18                for(i=2;i<=b-1;i++){
    19                 for(int j=1;j<=b-i;j++) printf(" ");
    20                 printf ("%c",a);
    21                 for(int j=1;j<=2*(i-1)-1;j++) printf(" ");
    22                 printf ("%c
    ",a);
    23             }
    24         }    
    25         for(i=1;i<=2*b-1;i++)printf("%c",a);
    26         printf("
    ");
    27     }
    28     return 0;
    29 }
    View Code

    hdu2092

    暴力模拟

     1 #include<stdio.h>
     2 #include<math.h>
     3 
     4 int main(){
     5     int  m,n;
     6     while(scanf("%d%d",&n,&m)!=EOF&&(n!=0||m!=0)){
     7         double d=n*n-4*m;
     8         if(d<0){
     9             printf("No
    ");
    10             continue;
    11         }
    12         else{
    13             double l1=n/2.0+sqrt(d)/2.0,l2=n/2.0-sqrt(d)/2.0;        
    14             int t1=l1,t2=l2;
    15             if(fabs(t1-l1)<1e-10&&fabs(t2-l2)<1e-10)printf("Yes
    ");
    16             else printf("No
    ");
    17         }
    18     }
    19     return 0;
    20 }
    View Code

    hdu2093

    麻烦一点的模拟

     1 #include<stdio.h>
     2 #include<string.h>
     3 struct list{
     4     char name[10];
     5     int am;
     6     int pt;
     7 }l[7];
     8 void ex(int i,int j){
     9     char temp[10];int t;
    10     {
    11         strcpy(temp,l[i].name);
    12         strcpy(l[i].name,l[j].name);
    13         strcpy(l[j].name,temp);
    14     }
    15     {
    16         t=l[i].am;
    17         l[i].am=l[j].am;
    18         l[j].am=t;
    19     }
    20     {
    21         t=l[i].pt;
    22         l[i].pt=l[j].pt;
    23         l[j].pt=t;
    24     }
    25 }
    26 int main(){
    27     int p[7];
    28     int n,m;
    29     while(scanf("%d%d",&n,&m)!=EOF){
    30         for(int q=1;q<=6;q++){
    31             l[q].am=l[q].pt=0;
    32             scanf("%s",l[q].name);
    33             for(int k=1;k<=n;k++){
    34                 int a;
    35                 scanf("%d",&a);
    36                 if(a>0){
    37                     l[q].am++;
    38                     l[q].pt+=a;
    39                 }
    40                 char b=getchar();
    41                 if(b=='('){
    42                     scanf("%d",&a);
    43                     l[q].pt+=m*a;
    44                     getchar();
    45                 }
    46             }
    47         
    48         }
    49         int i,j;
    50         for(i=1;i<=5;i++){
    51             for(j=i+1;j<=6;j++){
    52                 if(l[i].am<l[j].am){
    53                     ex(i,j);
    54                 }
    55                 else if(l[i].am==l[j].am&&l[i].pt>l[j].pt){
    56                     ex(i,j);
    57                 }
    58                 else if(l[i].am==l[j].am&&l[i].pt==l[j].pt&&strcmp(l[i].name,l[j].name)>0){
    59                     ex(i,j);
    60                 }
    61             }
    62         }
    63         for(i=1;i<=6;i++){
    64             printf("%-10s %2d %4d
    ",l[i].name,l[i].am,l[i].pt);
    65         }
    66     }
    67     return 0;
    68 }
    View Code

    hdu2094

    有胜负关系,判断是否能够决出冠军(唯一不败),map记录某个人是否失败过

     1 #include<stdio.h>
     2 #include<string.h>
     3 #include<map>
     4 #include<string>
     5 #include<iostream>
     6 using namespace std;
     7 
     8 int main(){
     9     int n;
    10     while(scanf("%d",&n)!=EOF&&n){
    11         map<string,int>m;
    12         int ans=0;
    13         while(n--){
    14             string a,b;
    15             cin>>a>>b;
    16             if(m[a]==0){
    17                 ans++;
    18                 m[a]=-1;
    19             }
    20             if(m[b]==0)m[b]++;
    21             else if(m[b]==-1){
    22                 m[b]=1;
    23                 ans--;
    24             }
    25         }
    26         if(ans==1)printf("Yes
    ");
    27         else printf("No
    ");
    28     }
    29     return 0;
    30 }
    View Code

    hdu2095

    找唯一一个只出现一次的数,将所有数异或,最后得到的就是出现一次的数

     1 #include<stdio.h>
     2 int main(){
     3     int n;
     4     while(scanf("%d",&n)!=EOF&&n!=0){
     5         int a=0,b;
     6         for(int q=1;q<=n;q++){
     7             scanf("%d",&b);
     8             a^=b;
     9         }
    10         printf("%d
    ",a);
    11     }
    12     return 0;
    13 }
    View Code

    hdu2096

    最后两位的A+B,模拟

     1 #include<stdio.h>
     2 int main(){
     3     int T;
     4     while(scanf("%d",&T)!=EOF){
     5         for(int q=1;q<=T;q++){
     6             int a,b;
     7             scanf("%d%d",&a,&b);
     8             a%=100;
     9             b%=100;
    10             int ans=(a+b)%100;
    11             printf("%d
    ",ans);
    12         }
    13 
    14     }
    15     return 0;
    16 }
    View Code

    hdu2097

    模拟

     1 #include<stdio.h>
     2 
     3 int main(){
     4     int n;
     5     while(scanf("%d",&n)!=EOF&&n!=0){
     6         int ans10=0,ans12=0,ans16=0;
     7         int t=n;
     8         while(t){
     9             ans10+=t%10;
    10             t/=10;
    11         }
    12         t=n;
    13         while(t){
    14             ans16+=t%16;
    15             t/=16;
    16         }
    17         t=n;
    18         while(t){
    19             ans12+=t%12;
    20             t/=12;
    21         }
    22         if(ans10==ans12&&ans12==ans16)printf("%d is a Sky Number.
    ",n);
    23         else printf("%d is not a Sky Number.
    ",n);
    24     }
    25     return 0;    
    26 }
    View Code
  • 相关阅读:
    HDU 5087 (线性DP+次大LIS)
    POJ 1064 (二分)
    Codeforces 176B (线性DP+字符串)
    POJ 3352 (边双连通分量)
    Codeforces 55D (数位DP+离散化+数论)
    POJ 2117 (割点+连通分量)
    POJ 1523 (割点+连通分量)
    POJ 3661 (线性DP)
    POJ 2955 (区间DP)
    LightOJ 1422 (区间DP)
  • 原文地址:https://www.cnblogs.com/cenariusxz/p/6578237.html
Copyright © 2011-2022 走看看