Problem Description

Input

Output

Sample Input

0051231232050775

Sample Output

0 77 12312320

import java.util.Scanner;
import java.util.*;
public class Main {
public static void main(String[] args) {
while(true){
Scanner sc = new Scanner(System.in);
String in = sc.next();
Scanner scanner = new Scanner(in);
Set map = new TreeSet();
scanner.useDelimiter("5+");
while(scanner.hasNextInt()){
}
Object[] a = map.toArray();
for(int i=0;i<a.length;i++){
if(i==a.length-1)
System.out.println(a[i]);
else
System.out.print(a[i]+" ");
}
}
}
}

50512312320555507750005
0 77 12312320

#include<stdio.h> int main(void) { int T = 0, a = 0, count_a = 0, count_b = 0; long long A[1000] = { 0 }, B[1000] = { 0 }, SUM[1000] = { 0 }; scanf("%d", &T); while (T > 0) { a++; scanf("%lld %lld", &A[a], &B[a]); SUM[a] = A[a] + B[a]; T--; } for (T = 1; T <= a; T++) { printf("Case %d:\n%lld + %lld = %lld\n\n", T, A[T], B[T], SUM[T]); } } 为什么不能这么做？？每次提交显示wrong answer！why？

http://acm.hdu.edu.cn/showproblem.php?pid=2022 杭电求解2022，带解析的那种，【害羞】

A number sequence is defined as follows: f(1) = 1, f(2) = 1, f(n) = (A * f(n - 1) + B * f(n - 2)) mod 7. Given A, B, and n, you are to calculate the value of f(n). 超过49个数之后一定会出现和之前的数组合相同的情况，这个我可以了解，但是 为什么最多经过49个数之后一定会出现周期呢？智商太低了，跪求解释

import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int m=0; int n=0; while(in.hasNext()){ m=in.nextInt(); n=in.nextInt(); if(m<n){ narcissus(m,n); } } } public static void narcissus(int m, int n){ int k=0; boolean mark = false; for(int i=m; i<=n; i++){ int sum=0; k=i; while(k!=0){ sum=sum+(k%10)*(k%10)*(k%10); k=k/10; } if(i==sum) { mark = true; System.out.print(i+" "); } } if(mark==false){ System.out.println("NO"); } System.out.println(); } }

``` #include<iostream> #include<string> using namespace std; int main() { string in; char temp; int flag, flagv; int vowel = 0; int consonant = 0; while (cin >> in) { if (in == "end") break; flag = 1; flagv = 0; temp = '~'; for (int i = 0; i < in.size(); i++) { if (in[i] == 'a'||in[i]=='e'||in[i]=='i'||in[i]=='o'||in[i]=='u') { consonant = 0; flagv = 1; vowel++; if (vowel == 3) { flag = 0; break; } } else { vowel = 0; consonant++; if (consonant == 3) { flag = 0; break; } } if (temp == in[i] &&in[i]!='e'&&in[i]!='o') { flag = 0; break; } else temp = in[i]; } cout << "<" << in << "> " << "is "; flag == 1&&flagv==1 ? cout << "acceptable" : cout << "not acceptable"; cout << endl; } return 0; } ```

![图片说明](https://img-ask.csdn.net/upload/201510/15/1444870735_573916.png) 我的代码 #include <stdio.h> int main(){ int n, i; int a, b; int x, sum; while(scanf("%d", &n) != EOF){ for (i = 0; i < n; i++){ scanf("%d", &a); for (b = 0; b < a; b++){ sum = 0; scanf("%d", &x); sum = sum + x; printf("%d", sum); printf("\n"); } } } return 0; }

Problem Description 网上流传一句话:"常在网上飘啊，哪能不挨刀啊～"。其实要想能安安心心地上网其实也不难，学点安全知识就可以。 首先，我们就要设置一个安全的密码。那什么样的密码才叫安全的呢？一般来说一个比较安全的密码至少应该满足下面两个条件： (1).密码长度大于等于8，且不要超过16。 (2).密码中的字符应该来自下面“字符类别”中四组中的至少三组。 这四个字符类别分别为： 1.大写字母：A,B,C...Z; 2.小写字母：a,b,c...z; 3.数字：0,1,2...9; 4.特殊符号：~,!,@,#,\$,%,^; 给你一个密码，你的任务就是判断它是不是一个安全的密码。 Input 输入数据第一行包含一个数M，接下有M行，每行一个密码（长度最大可能为50），密码仅包括上面的四类字符。 Output 对于每个测试实例，判断这个密码是不是一个安全的密码，是的话输出YES，否则输出NO。 Sample Input 3 a1b2c3d4 Linle@ACM ^~^@^@!% Sample Output NO YES NO
Random Walking 程序思路
Problem Description The Army of Coin-tossing Monkeys (ACM) is in the business of producing randomness. Good random numbers are important for many applications, such as cryptography, online gambling, randomized algorithms and panic attempts at solutions in the last few seconds of programming competitions. Recently, one of the best monkeys has had to retire. However, before he left, he invented a new, cheaper way to generate randomness compared to directly using the randomness generated by coin-tossing monkeys. The method starts by taking an undirected graph with 2n nodes labelled 0, 1, …, 2n - 1. To generate k random n-bit numbers, they will let the monkeys toss n coins to decide where on the graph to start. This node number is the first number output. The monkeys will then pick a random edge from this node, and jump to the node that this edge connects to. This new node will be the second random number output. They will then select a random edge from this node (possibly back to the node they arrived from in the last step), follow it and output the number of the node they landed on. This walk will continue until k numbers have been output. During experiments, the ACM has noticed that different graphs give different output distributions, some of them not very random. So, they have asked for your help testing the graphs to see if the randomness is of good enough quality to sell. They consider a graph good if, for each of the n bits in each of the k numbers generated, the probability that this bit is output as 1 is greater than 25% and smaller than 75%. Input The input will consist of several data sets. Each set will start with a line consisting of three numbers k, n, e separated by single spaces, where k is the number of n-bit numbers to be generated and e is the number of edges in the graph (1 ≤ k ≤ 100, 1 ≤ n ≤ 10 and 1 ≤ e ≤ 2000). The next e lines will consist of two space-separated integers v1, v2 where 0 ≤ v1, v2 < 2n and v1 ≠ v2. Edges are undirected and each node is guaranteed to have at least one edge. There may be multiple edges between the same pair of nodes. The last test case will be followed by a line with k = n = e = 0, which should not be processed. Output For each input case, output a single line consisting of the word Yes if the graph is good, and No otherwise. Sample Input 10 2 3 0 3 1 3 2 3 5 2 4 0 1 0 3 1 2 2 3 0 0 0 Sample Output No Yes
Catch the Bus!
Problem Description ACM needs to deliver marketing materials to one of their clients. Both ACM and the client employ students to make such deliveries. And these students use public buses to move throughout the city. Sometimes, it is necessary to pass the materials as fast as possible. You are given bus timetables and your task is to find the fastest way for two students to meet at some stop. The place of the meeting is not important, they only need to meet as early as possible. Students may change between any two bus routes at stops that are common for both routes. At least two minutes are needed for every such change. No additional time is necessary to get on the first bus or to meet the other student in the target stop. Input The input contains a sequence of several scenarios, the sequence is terminated by a line containing negative number. Each scenario begins with a non-negative integer L, the number of bus routes that operate in the city (L ≤ 1000). Every route is then described by two lines. The first line contains names of stops that the bus runs through. Between each consecutive stops, there is a non-negative integer specifying the number of minutes required to travel between these stops with the given bus. The last stop is followed by a negative number. The second line of each bus route contains non-negative integers separated with spaces. The first integer H gives the number of buses that depart the initial stop in every hour (H ≤ 60). The remaining H integers are always distinct and sorted ascendingly, they list the minutes of departure (between 0 and 59). The timetable repeats every hour. For example, if the second line says “2 00 30”, the buses leave the initial stop at 12:00, 12:30, 13:00, 13:30, 14:00, etc. After the description of routes, there are two lines that specify the initial position of students. Each of them will contain time in a standard 24-hour format (one or two digits for hours, colon, and two digits for minutes) and a stop name. All numbers, times, and stop names will be separated with a single space. Stop names are case-sensitive and may be composed only from lower-case and upper-case letters, their length will not exceed 30 characters. The total number of stops will be at most 1000, the number of stops on a single route will not exceed 100. The time between any two consecutive stops will be at most one hour. The routes are considered one-way, if they operate in both directions, they will be given as two separate routes. A route may run through the same stop several times. Output For each test scenario, output a single line containing the earliest possible time the students can meet at any of the stops. The time must appear in the standard 24-hour format, hours given as a number between 0 and 23, then colon and minutes between 0 and 59. For hour values less than 10, only one digit must be used. Be aware of the fact that both students start their trip on the same day but may meet on another day, if the required time exceeds midnight. If the students are not able to meet in some scenario, output the words “No connection” instead of the time. Sample Input 4 Hradcanska 2 Malostranska 2 Staromestska 2 Mustek 1 Muzeum -1 10 00 06 12 18 24 30 36 42 48 54 Muzeum 1 Mustek 2 Staromestska 2 Malostranska 2 Hradcanska -1 10 03 09 15 21 27 33 39 45 51 57 Andel 2 Karlovo 1 Narodni 2 Mustek 2 Florenc -1 6 00 10 20 30 40 50 Florenc 2 Mustek 2 Narodni 3 Karlovo 1 Andel -1 6 02 12 22 32 42 52 12:00 Hradcanska 12:11 Andel 1 Hradcanska 2 Malostranska 2 Staromestska 2 Mustek 1 Muzeum 2 Hradcanska -1 10 00 06 12 18 24 30 36 42 48 54 12:00 Mustek 12:00 Andel -1 Sample Output 12:20 No connection

#include<stdio.h> int main() { long n,r; char a[10000]; while(scanf("%d%d",&n,&r) == 2) { if(n == 0) printf("0\n"); else { int i = 0; if(n<0){n=-n;printf("-");} while(n > 0) { a[i++] = n%r; n=n/r; } int j = i-1; for(; j >= 0; j--) { if(a[j] > 10) printf("%c",a[j]-10+'A'); else printf("%d",a[j]); } putchar('\n'); } } return 0; }

import java.math.BigInteger; import java.util.Scanner; public class A1042 { private static Scanner sc; public static void main(String []args){ sc = new Scanner(System.in); BigInteger n = sc.nextBigInteger(); while(n.intValue()<=10000){ if(!n.equals(BigInteger.valueOf(1))){ n = n.multiply(n.subtract(BigInteger.valueOf(1))); } System.out.println(n); n = sc.nextBigInteger(); } } } 为什么自己运行结果是正确的却编译不通过，提示Compilation Error

Crystal Ball Factory 最小花费题
Problem Description The Astrologically Clairvoyant Manufacturers (ACM),a pioneer in future-predicting technology, just landed a contract to manufacture crystal balls for weather forecasters around the world. Every week, a variable number of crystal balls needs to be delivered; the required amount for each week is specified in the contract. Crystal balls are made from the highest-quality crystal, whose price fluctuates from week to week. Fortunately, the ACM is able to foresee the price of crystal for the coming weeks, thanks to its own future-predicting technology. When the price is low, the ACM would like to buy crystal and manufacture crystal balls, storing any excess in their warehouse. On the other hand, in weeks for which the price is high, ACM would rather use the crystal balls stored in the warehouse to satisfy the demand specified in their contract. However, since there is a also a fixed weekly cost to store each crystal ball in the warehouse, and an initial cost for turning on the manufacturing machines and producing a non-zero quantity of crystal balls, the decision is not always simple. Can you help them fulfill their contract at minimal cost? Input The first line of each test case (representing a contract) will contain the number of weeks for which the contract will last. The next line will contain the non-negative integers b, k and n, where b is the base cost for manufacturing a non-zero quantity of crystal balls on a given week, k is the cost for storing each crystal ball in the warehouse for a week, and n is the maximum capacity of the warehouse. The following lines will describe the weeks specified in the contract in chronological order. Each week is described by a single line which will contain a pair of non-negative integers c and r, where c is the cost for manufacturing a new crystal ball using new crystal bought this week, and r is the number of crystal balls which must be delivered this week. A crystal ball can be manufactured and delivered in the same week if appropriate, in which case it won’t need to be stored in the warehouse at all. The last line of the input will contain the integer 0 and should not be processed. Output For each test case, output the minimum amount which the ACM will have to spend in order to fulfill the entire contract. All the numbers in the input will be at most 1000. Sample Input 4 1 0 1000 1 1 12 4 1 0 1000 1000 2 0 100 1 1 1000 1000 101 0 Sample Output 1007 101101
Simulation? 模拟的问题
Problem Description A computer simulation, a computer model, or a computational model is a computer program, or network of computers, that attempts to simulate an abstract model of a particular system. Computer simulations have become a useful part of mathematical modeling of many natural systems in physics, astrophysics, chemistry and biology, human systems in economics, psychology, social science, and engineering, of course, also computer. “Fundamentals of compiling” is an important course for computer science students. In this course, most of us are asked to write a compiler to simulate how a programming language executes. Today, boring iSea invites a new programming language, whose name is Abnormal Cute Micro (ACM) language, and, YOU are assigned the task to write a compiler for it. ACM language only contains two kinds of variables and a few kinds of operations or functions, and here are some BNF-like rules for ACM. Also, here is some explanation for these rules: 1) In ACM expressions, use exactly one blank to separate variables and operators, and as the rule indicates, the operator should apply right to left, for example, the result of “1 - 2 - 3" should be 2. 2) In the build function, use exactly one blank to separate integers, too. 3) Beside there are brackets in function, no other bracket exists. 4) All the variables are conformable, and never exceed 10000. Given an ACM expression, your task is output its value. If the result is a integer, just report it, otherwise report an array using the format “{integer_0, integer_1, … , integer_n}”. Input The first line contains a single integer T, indicating the number of test cases. Each test case includes a string indicating an valid ACM expression you have to process. Technical Specification 1. 1 <= T <= 100 2. 1 <= |S| <= 100, |S| indicating the length of the string. Output For each test case, output the case number first, then the result variable. Sample Input 10 1 + 1 1 - 2 - 3 dance(3) vary(2) * 2 vary(sum(dance(5) - 1)) dance(dance(-3)) 1 - 2 - 3 * vary(dull(build(1 2 3))) dance(dance(dance(dance(dance(2))))) sum(vary(100)) - sum(build(3038)) build(sum(vary(2)) dull(build(1 0)) 2 dull(dance(2))) - build(1 1 1 1) Sample Output Case 1: 2 Case 2: 2 Case 3: {3, -2, 1} Case 4: {2, 4} Case 5: {2, 1} Case 6: -4 Case 7: {2, 5} Case 8: {4, -3, 2, -1} Case 9: 2012 Case 10: {2, 0, 1, 2}

Problem Description potato老师虽然很喜欢教书，但是迫于生活压力，不得不想办法在业余时间挣点外快以养家糊口。 “做什么比较挣钱呢？筛沙子没力气，看大门又不够帅...”potato老师很是无奈。 “张艺谋比你还难看，现在多有钱呀，听说还要导演奥运开幕式呢！你为什么不去娱乐圈发展呢？”lwg在一旁出主意。 嗯，也是，为了生存，就委屈点到娱乐圈混混吧，马上就拍一部激光电影《杭电记忆——回来我的爱》。 说干就干，马上海选女主角（和老谋子学的，此举可以吸引媒体的眼球，呵呵），并且特别规定，演员必须具有ac的基本功，否则直接out! 由于策划师风之鱼（大师级水王）宣传到位，来应聘的MM很多，当然包括nit的蛋糕妹妹等呼声很高的美女，就连zjut的jqw都男扮女装来应聘（还好被安全顾问hdu_Bin-Laden认出，给轰走了），看来娱乐圈比acm还吸引人哪... 面试那天，刚好来了m*n个MM，站成一个m*n的队列，副导演Fe(OH)2为每个MM打了分数，分数都是32位有符号整数。 一开始我很纳闷：分数怎么还有负的？Fe(OH)2解释说，根据选拔规则，头发染成黄色、化妆太浓、穿的太少等等都要扣分数的，扣的多了就可能是负分了，当然，如果发现话语中夹有日语，就直接给-2147483648分了。 分数送上来了，是我做决定的时候了，我的一个选拔原则是，要选一个面试分数绝对值（必须还是32位整数）最大的MM。 特别说明：如果不幸选中一个负分的MM,也没关系，因为我觉得，如果不能吸引你，那要想法恶心你。 Input 输入数据有多组，每组的第一行是两个整数m和n，表示应聘MM的总共的行列数，然后是m行整数，每行有n个，m和n的定义见题目的描述。 Output 对于每组输入数据，输出三个整数x,y和s，分别表示选中的MM的行号、列号和分数。 note:行号和列号从一开始，如果有多个MM的分数绝对值一样，那么输出排在最前面的一个（即行号最小的那个，如果行号相同则取列号最小的那个）。 Sample Input 2 3 1 4 -3 -7 3 0 Sample Output 2 1 -7

#include<stdio.h> #include<string> int c[10086]; int main() { int i,j,l,n,k,h; while(scanf("%d",&n)!=EOF) { memset(c,0,sizeof(c)); c[0]=1; k=0; if(n==0) printf("1\n"); else { for(j=1;j<=n;j++) { for(i=0;i<=k;i++) { c[i]=c[i]*j; } for(h=0;h<=k;h++) { if(c[h]>9999) { c[h+1]=c[h+1]+c[h]/10000; c[h]=c[h]%10000; if(c[k+1]>0) //*为什么这个if判断不能少 按道理不是一定会有c[k+1]>0吗，没有这一句我的结果前面多了两个0*// k++; } } } for(l=k;l>=0;l--) { if(l==k) printf("%d",c[l]); else { if(c[l]<10&&c[l]>=0) printf("000%d",c[l]); else if(c[l]<100&&c[l]>=10) printf("00%d",c[l]); else if(c[l]<1000&&c[l]>=100) printf("0%d",c[l]); else if(c[l]>=1000) printf("%d",c[l]); } } printf("\n"); } } return 0; }
Java学习的正确打开方式

linux系列之常用运维命令整理笔录

Python十大装B语法
Python 是一种代表简单思想的语言，其语法相对简单，很容易上手。不过，如果就此小视 Python 语法的精妙和深邃，那就大错特错了。本文精心筛选了最能展现 Python 语法之精妙的十个知识点，并附上详细的实例代码。如能在实战中融会贯通、灵活使用，必将使代码更为精炼、高效，同时也会极大提升代码B格，使之看上去更老练，读起来更优雅。

Docker 技术发展为微服务落地提供了更加便利的环境，使用 Docker 部署 Spring Boot 其实非常简单，这篇文章我们就来简单学习下。首先构建一个简单的 S...

SQL-小白最佳入门sql查询一

redis分布式锁，面试官请随便问，我都会

Nginx 原理和架构
Nginx 是一个免费的，开源的，高性能的 HTTP 服务器和反向代理，以及 IMAP / POP3 代理服务器。Nginx 以其高性能，稳定性，丰富的功能，简单的配置和低资源消耗而闻名。 Nginx 的整体架构 Nginx 里有一个 master 进程和多个 worker 进程。master 进程并不处理网络请求，主要负责调度工作进程：加载配置、启动工作进程及非停升级。worker 进程负责处...
“狗屁不通文章生成器”登顶GitHub热榜，分分钟写出万字形式主义大作

《程序人生》系列-这个程序员只用了20行代码就拿了冠军

11月8日，由中国信息通信研究院、中国通信标准化协会、中国互联网协会、可信区块链推进计划联合主办，科技行者协办的2019可信区块链峰会将在北京悠唐皇冠假日酒店开幕。 　　区块链技术被认为是继蒸汽机、电力、互联网之后，下一代颠覆性的核心技术。如果说蒸汽机释放了人类的生产力，电力解决了人类基本的生活需求，互联网彻底改变了信息传递的方式，区块链作为构造信任的技术有重要的价值。 　　1...
Java世界最常用的工具类库
Apache Commons Apache Commons有很多子项目 Google Guava 参考博客

【技巧总结】位运算装逼指南

Android 9.0 init 启动流程