杭电1020
来源:互联网 发布:淘宝店铺地址是什么 编辑:程序博客网 时间:2024/05/08 16:56
杭电1020—简单字符串处理
http://acm.hdu.edu.cn/showproblem.php?pid=1020
Encoding
Time Limit:2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 28085 Accepted Submission(s): 12430
Problem Description
Given a string containing only 'A' - 'Z', we couldencode it using the following method:
1. Each sub-string containing k same characters should be encoded to"kX" where "X" is the only character in this sub-string.
2. If the length of the sub-string is 1, '1' should be ignored.
Input
The first line contains an integer N (1 <= N<= 100) which indicates the number of test cases. The next N lines contain Nstrings. Each string consists of only 'A' - 'Z' and the length is less than10000.
Output
For each test case, output the encoded string in aline.
Sample Input
2
ABC
ABBCCC
Sample Output
ABC
A2B3C
题目相对而言还是比较简单易理解的,大小写是糊弄你的,不用判断,甚至可以输入数字或者其他符号,照样能AC。只是要注意如果输入的是 ABC ,输出中并没有”1”;
代码:
#include<iostream>#include<cstdio>//#include<cstring>//#include<cmath>using namespace std;int fac(int n){ int carry,j; int a[34001]; int digit; int temp,i; a[0]=1;digit=1; for(i=2; i<=n; i++) { for(carry=0,j=1; j<=digit; ++j) { temp=a[j-1]*i+carry; a[j-1]=temp%10; carry=temp/10; } while(carry) { a[++digit-1]=carry%10; carry/=10; } } i=0; while(!a[i]) i++; printf("%d",a[i]); printf("\n"); return 0;}int main(){ int n; while(cin>>n) fac(n); return 0;}
- 杭电 1020 Encoding
- 杭电1020 Encoding
- 杭电1020题
- 杭电1020
- 杭电 1020
- 杭电1020
- 杭电1020
- 杭电1020
- 杭电 acm 1020
- 杭电1020
- 杭电1020 Encoding
- 杭电1020 Encoding
- 杭电1020Encoding
- 杭电 1020 Encoding
- 杭电Hd 1020 Encoding
- 杭电acm 1020 Encoding
- 杭电ACM 1020 Encoding
- 杭电 HDU 1020 Encoding
- C语言同步和异步
- Permutation Sequence
- Length of Last Word
- Insert Interval
- nodejs Stream使用中的陷阱
- 杭电1020
- POJ 1077 解题报告
- 杭电1021
- 492C - Vanya and Exams
- 杭电2037
- Maximum Product Subarray
- SIFT算法詳解
- 高斯模糊實現小結
- 如何将IE 11 改为 IE 8