码迷,mamicode.com
首页 > 其他好文 > 详细

USACO Section 2.1: Preface Numbering

时间:2014-09-23 13:29:54      阅读:155      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   io   os   ar   for   div   sp   

看网上的,太琐碎

 1 /*
 2 ID: yingzho2
 3 PROG: preface
 4 LANG: C++
 5  */
 6 #include <iostream>
 7 #include <fstream>
 8 #include <string>
 9 #include <map>
10 #include <vector>
11 #include <set>
12 #include <algorithm>
13 #include <queue>
14 #include <cmath>
15 #include <list>
16 #include <cstring>
17 #include <cstdlib>
18 #include <limits>
19 #include <stack>
20 
21 using namespace std;
22 
23 ofstream fout ("preface.out");
24 ifstream fin ("preface.in");
25 const char ch[8]={4,I,V,X,L,C,D,M};
26 const int a[4][10]={
27     0,0,0,0,0,0,0,0,0,0,
28     0,1,2,3,1,0,1,2,3,1,
29     0,0,0,0,1,1,1,1,1,0,
30     0,0,0,0,0,0,0,0,0,1};
31 int ans[13];
32 int n,i,j,t;
33 
34 int main(){
35     fin >> n;
36     for (int k=1;k<=n;++k){
37         t=k;
38         for (i=0;i<=3;++i){
39             for (j=1;j<=3;++j)
40                 ans[i*2+j]+=a[j][t%10];
41             t=t/10;
42             if (t==0) break;
43         }
44     }
45     for (i=1;i<=7;++i)
46         if (ans[i]!=0) fout << ch[i] << " " << ans[i] << endl;
47     return 0;
48 }

 

USACO Section 2.1: Preface Numbering

标签:style   blog   color   io   os   ar   for   div   sp   

原文地址:http://www.cnblogs.com/yingzhongwen/p/3987771.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!