PAT Basic 1062

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PAT Basic 1062相关的知识,希望对你有一定的参考价值。

鏍囩锛?a href='http://www.mamicode.com/so/1/%e8%be%97%e8%bd%ac%e7%9b%b8%e9%99%a4%e6%b3%95' title='杈楄浆鐩搁櫎娉?>杈楄浆鐩搁櫎娉?/a>   -o   html   fonts   str   tin   琛ㄧず   ups   

1062 鏈€绠€鍒嗘暟

涓€涓垎鏁颁竴鑸啓鎴愪袱涓暣鏁扮浉闄ょ殑褰㈠紡锛?span class="katex">N/M锛屽叾涓?M 涓嶄负0銆傛渶绠€鍒嗘暟鏄寚鍒嗗瓙鍜屽垎姣嶆病鏈夊叕绾︽暟鐨勫垎鏁拌〃绀哄舰寮忋€?/span>

鐜扮粰瀹氫袱涓笉鐩哥瓑鐨勬鍒嗘暟 N?1??/M?1?? 鍜?N?2??/M?2??锛岃姹備綘鎸変粠灏忓埌澶х殑椤哄簭鍒楀嚭瀹冧滑涔嬮棿鍒嗘瘝涓?K 鐨勬渶绠€鍒嗘暟銆?/span>

杈撳叆鏍煎紡锛?/span>

杈撳叆鍦ㄤ竴琛屼腑鎸?N/M 鐨勬牸寮忕粰鍑轰袱涓鍒嗘暟锛岄殢鍚庢槸涓€涓鏁存暟鍒嗘瘝 K锛屽叾闂翠互绌烘牸鍒嗛殧銆傞鐩繚璇佺粰鍑虹殑鎵€鏈夋暣鏁伴兘涓嶈秴杩?1000銆?/span>

杈撳嚭鏍煎紡锛?/span>

鍦ㄤ竴琛屼腑鎸?N/M 鐨勬牸寮忓垪鍑轰袱涓粰瀹氬垎鏁颁箣闂村垎姣嶄负 K 鐨勬墍鏈夋渶绠€鍒嗘暟锛屾寜浠庡皬鍒板ぇ鐨勯『搴忥紝鍏堕棿浠?1 涓┖鏍煎垎闅斻€傝棣栧熬涓嶅緱鏈夊浣欑┖鏍笺€傞鐩繚璇佽嚦灏戞湁 1 涓緭鍑恒€?/span>

杈撳叆鏍蜂緥锛?/span>

7/18 13/20 12

杈撳嚭鏍蜂緥锛?/span>

5/12 7/12

銆€銆€棰樿В锛氳繖閬撻瑕佹敞鎰忥紝绗竴涓垎鏁颁笉涓€瀹氭瘮绗簩涓垎鏁板皬锛岄渶瑕佸湪寮€澶村垽鏂竴涓嬫墠鍙互銆?br>銆€銆€鐭ヨ瘑鐐瑰涔狅細杈楄浆鐩搁櫎娉?br>
1 int f(int a, int b){
2     if( a%b == 0)
3         return b;
4     else
5         return f(b,a%b);
6 }

 


浠g爜濡備笅锛?br>
 1 #include<iostream>
 2 
 3 using namespace std;
 4 
 5 int f(int a, int b){
 6     if( a%b == 0)
 7         return b;
 8     else
 9         return f(b,a%b);
10 }
11 
12 int main()
13 {
14     double n1, n2, m1, m2, k;
15     int t, ac = 0;
16     scanf("%lf/%lf %lf/%lf %lf",&n1, &m1, &n2, &m2, &k);
17     if( n2/m2 < n1/m1){
18         t = n2;
19         n2 = n1;
20         n1 = t;
21         t = m1;
22         m1 = m2;
23         m2 = t; 
24     }
25     for( double i = 1; i/k < n2/m2; i++){
26         if( i/k <= n1/m1) continue;
27         if( k != 1){ 
28             if( !(f(i,k) == 1))
29                  continue;    
30         }
31         if(!ac)
32             ac = 1;
33         else
34             printf(" ");
35         printf("%d/%d",(int)i,(int)k);
36     }
37     return 0;
38 } 

 

 



以上是关于PAT Basic 1062的主要内容,如果未能解决你的问题,请参考以下文章

PAT Basic 1049

PAT Basic 1078

PAT乙级1062

PAT-B 1015. 德才论(同PAT 1062. Talent and Virtue)

1062. Talent and Virtue (25)排序——PAT (Advanced Level) Practise

PAT 1062 Talent and Virtue[难]