zoukankan      html  css  js  c++  java
  • The Last Practice

    Problem Description
    Tomorrow is contest day, Are you all ready?
    We have been training for 45 days, and all guys must be tired.But , you are so lucky comparing with many excellent boys who have no chance to attend the Province-Final.

    Now, your task is relaxing yourself and making the last practice. I guess that at least there are 2 problems which are easier than this problem.
    what does this problem describe?
    Give you a positive integer, please split it to some prime numbers, and you can got it through sample input and sample output.
     
    Input
    Input file contains multiple test case, each case consists of a positive integer n(1<n<65536), one per line. a negative terminates the input, and it should not to be processed.
     
    Output
    For each test case you should output its factor as sample output (prime factor must come forth ascending ), there is a blank line between outputs.
     
    Sample Input
    60
    12
    -1
     
    Sample Output
    Case 1.
    2 2 3 1 5 1
     
     
    Case 2.
    2 2 3 1
     
    Hint
    60=2^2*3^1*5^1
     
     
     1 #include <stdio.h>
     2 #include <string.h>
     3 
     4 int main(){
     5     int number;
     6     int i;
     7     int amount[65536];
     8     int temp;
     9     int time;
    10 
    11     time=1;
    12 
    13     while(1){
    14         scanf("%d",&number);
    15 
    16         if(number<0)
    17             break;
    18 
    19         if(time!=1)
    20             printf("
    ");
    21 
    22         memset(amount,0,65536*sizeof(int));
    23         temp=number;
    24 
    25         while(1){
    26             for(i=2;i<=temp;i++){
    27                 if(temp%i==0){
    28                     amount[i]++;
    29                     temp/=i;
    30                     break;
    31                 }
    32 
    33             }
    34 
    35             if(temp==1)
    36                 break;
    37         }
    38 
    39         printf("Case %d.
    ",time);
    40         time++;
    41 
    42         for(i=2;i<=number;i++){
    43             if(amount[i]!=0){
    44                 printf("%d %d ",i,amount[i]);
    45             }
    46         }
    47 
    48         printf("
    ");
    49     }
    50 
    51     return 0;
    52 }
  • 相关阅读:
    mac本地如何搭建IPv6环境测试你的APP
    消息通知机制(NSNotification和NSNotificationCenter)
    Xcode 6制作动态及静态Framework
    html格式化输出JSON( 测试接口)
    UIContainerView纯代码实现及原理介绍
    CocoaPods 详解之----更新篇
    使用Cocoapods创建私有podspec
    ios高效开发-正确的使用枚举(Enum)
    在Xcode6中搭建Python开发环境
    用Swift语言做App开发之单元测试
  • 原文地址:https://www.cnblogs.com/zqxLonely/p/4085038.html
Copyright © 2011-2022 走看看