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("\n");
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.\n",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("\n");
49     }
50 
51     return 0;
52 }

 

转载于:https://www.cnblogs.com/zqxLonely/p/4085038.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
翻译一下function format = stlGetFormat(fileName) %STLGETFORMAT identifies the format of the STL file and returns 'binary' or %'ascii' fid = fopen(fileName); % Check the file size first, since binary files MUST have a size of 84+(50*n) fseek(fid,0,1); % Go to the end of the file fidSIZE = ftell(fid); % Check the size of the file if rem(fidSIZE-84,50) > 0 format = 'ascii'; else % Files with a size of 84+(50*n), might be either ascii or binary... % Read first 80 characters of the file. % For an ASCII file, the data should begin immediately (give or take a few % blank lines or spaces) and the first word must be 'solid'. % For a binary file, the first 80 characters contains the header. % It is bad practice to begin the header of a binary file with the word % 'solid', so it can be used to identify whether the file is ASCII or % binary. fseek(fid,0,-1); % go to the beginning of the file header = strtrim(char(fread(fid,80,'uchar')')); % trim leading and trailing spaces isSolid = strcmp(header(1:min(5,length(header))),'solid'); % take first 5 char fseek(fid,-80,1); % go to the end of the file minus 80 characters tail = char(fread(fid,80,'uchar')'); isEndSolid = findstr(tail,'endsolid'); % Double check by reading the last 80 characters of the file. % For an ASCII file, the data should end (give or take a few % blank lines or spaces) with 'endsolid <object_name>'. % If the last 80 characters contains the word 'endsolid' then this % confirms that the file is indeed ASCII. if isSolid & isEndSolid format = 'ascii'; else format = 'binary'; end end fclose(fid);
05-18

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值