准备复试的每一天---- 杭电OJ记录

杭电oj 2040

int qhs(int num1, int num2) {

    vector<int> num1sy, num2sy;

    for(int i=1; i<num1; ++i)

         if(num1%i==0) num1sy.push_back(i);

    for(int i=1; i<num2; ++i)

         if(num2%i==0) num2sy.push_back(i);

    int sum1=0, sum2=0;

    for(int i=0; i<num1sy.size(); ++i) {

         sum1 = sum1 + num1sy[i];

    }

    for(int i=0; i<num2sy.size(); ++i) {

         sum2 = sum2+ num2sy[i];

    }

    if(sum1==num2&&sum2==num1) return 1;

    else return 0;

}

杭电oj 2027

int main(int argc, char** argv) {

    int num = 0;

    vector<string> strlist;

    scanf("%d", &num);

    getchar();

    while(num--){

         char str[200];

         gets(str);

         string a = str;

         strlist.push_back(a);

    }

    for(int i=0;i<strlist.size();++i){

         int count[5]={0, 0, 0, 0, 0};

         string s_tmp = strlist[i];

         for(int j=0;j<s_tmp.length();++j){

               if(s_tmp[j]=='a') count[0]++;

               if(s_tmp[j]=='e') count[1]++;

               if(s_tmp[j]=='i') count[2]++;

               if(s_tmp[j]=='o') count[3]++;

               if(s_tmp[j]=='u') count[4]++;

         }

         printf("a:%d\n", count[0]);

         printf("e:%d\n", count[1]);

         printf("i:%d\n", count[2]);

         printf("o:%d\n", count[3]);

         printf("u:%d\n", count[4]);

         if(i!=strlist.size()-1) printf("\n");

    }

    return 0;

}

杭电oj 2009

int main(int argc, char** argv) {

    vector<float> num;

    vector<int> count;

    int i=0;

    float tmp; int tmp_c;

    while(scanf("%f%d", &tmp, &tmp_c)!=EOF){

         num.push_back(tmp);

         count.push_back(tmp_c);

    }

    if(count.size()==0) {

   

         return 0;

    }

    for(int i=0;i<num.size();++i){

         float a, b, sum=0;

         a = num[i];

         while(count[i]--){

               sum = sum + a;

               a = sqrt(a);

         }

         printf("%.2f", sum);

//       if(i!=num.size()-1)

               printf("\n");

    }

    return 0;

}

posted @ 2021-01-20 16:33  wkfxm  阅读(124)  评论(0编辑  收藏  举报