微前端架构如何改变企业的开发模式与效率提升
622
2022-10-18
HDOJ--2161 prmes + HDOJ--2551 竹青遍野
Primes
Problem Description
Write a program to read in a list of integers and determine whether or not each number is prime. A number, n, is prime if its only divisors are 1 and n. For this problem, the numbers 1 and 2 are not considered primes.
Input
Each input line contains a single integer. The list of integers is terminated with a number<= 0. You may assume that the input contains at most 250 numbers and each number is less than or equal to 16000.
Output
The output should consists of one line for every number, where each line first lists the problem number, followed by a colon and space, followed by "yes" or "no".
Sample Input
1 2 3 4 5 17 0
Sample Output
1: no 2: no 3: yes 4: no 5: yes 6: yes
竹青遍野:
Problem Description
"临流揽镜曳双魂 落红逐青裙 依稀往梦幻如真 泪湿千里云" 在MCA山上,除了住着众多武林豪侠之外,还生活着一个低调的世外高人,他本名逐青裙,因为经常被人叫做"竹蜻蜓",终改名逐青,常年隐居于山中,不再见外人.根据山上附近居民所流传的说法,逐青有一个很奇怪的癖好,从他住进来那天开始,他就开始在他的院子周围种竹子,第1个月种1根竹子,第2个月种8根竹子,第3个月种27根竹子...第N个月就种(N^3)根竹子.他说当他种下第X根竹子那一刻,就是他重出江湖之时!告诉你X的值,你能算出逐青的复出会是在第几个月吗?
Input
首先输入一个t,表示有t组数据,跟着t行.每行是一个整数X,X < 1000000000
Output
输出一个整数n,表示在第n个月复出
Sample Input
3 1 2 10
Sample Output
1 2 3
import java.util.Scanner;public class Main { /** * 直接打表就可以了~~~~~ * 将第i个月能种多少根竹子;存在dp[i]中 * 再从dp.length-1依次1在最小的找 直到表中找到大于dp[i] * 这个时候i+1就是答案 */ static int dp[] = new int[253]; public static void main(String[] args) { dabiao(); Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while(t-->0){ int x = sc.nextInt(); for(int i=dp.length-1;i>=0;i--){ if(x > dp[i]){ System.out.println(i+1); break; } } } } public static void dabiao(){ dp[0]=0; for(int i=1;i
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~