PAT乙级1088-----三人行 (20分)

1088 三人行 (20分)

输入样例 1:

48 3 7

输出样例 1:

48 Ping Cong Gai

输入样例 2:

48 11 6

输出样例 2:

No Solution

思路:1.丙的能力值有可能是小数因此要用double

首次通过代码:

 1 #include<stdio.h>
 2 #include<stdlib.h>
 3 #include<math.h>
 4
 5
 6
 7 int main(){
 8     int m,x,y;
 9     int flag=1;
10     scanf("%d %d %d",&m,&x,&y);
11     for(int i=99;i>=10;i--){
12         int j=i/10+(i%10)*10;
13         double k=(double)j/y;
14             if(fabs(k*x-abs(i-j))<=1e-10){
15               printf("%d ",i);
16               if(m>i) printf("Gai ");
17               else if(m==i) printf("Ping ");
18               else printf("Cong ");
19               if(m>j) printf("Gai ");
20               else if(m==j) printf("Ping ");
21               else printf("Cong ");
22               if(m>k) printf("Gai");
23               else if(m==k) printf("Ping");
24               else printf("Cong");
25               flag=0;
26               break;
27             }
28         }
29
30     if(flag)
31     printf("No Solution");
32     return 0;
33 }

原文地址:https://www.cnblogs.com/a982961222/p/12402040.html

时间: 2024-10-12 13:08:39

PAT乙级1088-----三人行 (20分)的相关文章

PAT Basic 1088 三人行 (20 分)

子曰:“三人行,必有我师焉.择其善者而从之,其不善者而改之.” 本题给定甲.乙.丙三个人的能力值关系为:甲的能力值确定是 2 位正整数:把甲的能力值的 2 个数字调换位置就是乙的能力值:甲乙两人能力差是丙的能力值的 X 倍:乙的能力值是丙的 Y 倍.请你指出谁比你强应“从之”,谁比你弱应“改之”. 输入格式: 输入在一行中给出三个数,依次为:M(你自己的能力值).X 和 Y.三个数字均为不超过 1000 的正整数. 输出格式: 在一行中首先输出甲的能力值,随后依次输出甲.乙.丙三人与你的关系:如

pat 1035 Password(20 分)

1035 Password(20 分) To prepare for PAT, the judge sometimes has to generate random passwords for the users. The problem is that there are always some confusing passwords since it is hard to distinguish 1 (one) from l (L in lowercase), or 0 (zero) fro

pat 1077 Kuchiguse(20 分) (字典树)

1077 Kuchiguse(20 分) The Japanese language is notorious for its sentence ending particles. Personal preference of such particles can be considered as a reflection of the speaker's personality. Such a preference is called "Kuchiguse" and is often

[PTA] PAT(A) 1008 Elevator (20 分)

目录 Problem Description Input Output Sample Sample Input Sample Output Solution Analysis Code Problem portal: 1008 Elevator (20 分) Description  The highest building in our city has only one elevator. A request list is made up with $N$ positive numbers

PAT甲级——1035 Password (20分)

To prepare for PAT, the judge sometimes has to generate random passwords for the users. The problem is that there are always some confusing passwords since it is hard to distinguish 1 (one) from l (L in lowercase), or 0 (zero) from O (o in uppercase)

PAT Advanced 1035 Password (20分)

To prepare for PAT, the judge sometimes has to generate random passwords for the users. The problem is that there are always some confusing passwords since it is hard to distinguish 1 (one) from l (L in lowercase), or 0 (zero) from O (o in uppercase)

PAT 数列求和-加强版&#160;&#160;&#160;(20分)(简单模拟)

给定某数字A(1≤A≤9)以及非负整数N(0≤N≤100000),求数列之和S=A+AA+AAA+?+AA?A(N个A).例如A=1, N=3时,S=1+11+111=123 输入格式: 输入数字A与非负整数N. 输出格式: 输出其N项数列之和S的值. 输入样例: 1 3 输出样例: 123 1 #include<cstdio> 2 #include<iostream> 3 #include<algorithm> 4 #include<cmath> 5 #i

pat 1062 最简分数(20 分)错误

一个分数一般写成两个整数相除的形式:N/M,其中 M 不为0.最简分数是指分子和分母没有公约数的分数表示形式. 现给定两个不相等的正分数 N?1??/M?1?? 和 N?2??/M?2??,要求你按从小到大的顺序列出它们之间分母为 K 的最简分数. 输入格式: 输入在一行中按 N/M 的格式给出两个正分数,随后是一个正整数分母 K,其间以空格分隔.题目保证给出的所有整数都不超过 1000. 输出格式: 在一行中按 N/M 的格式列出两个给定分数之间分母为 K 的所有最简分数,按从小到大的顺序,其

[PAT] 1077 Kuchiguse (20 分)Java

The Japanese language is notorious for its sentence ending particles. Personal preference of such particles can be considered as a reflection of the speaker's personality. Such a preference is called "Kuchiguse" and is often exaggerated artistic