import java.util.Arrays;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
while(cin.hasNext()){
String s = cin.next();
char[] str = s.toCharArray();
Arrays.sort(str);
for(int i = 0; i < 2; i++){
System.out.print(str[i] + " ");
}
System.out.println(str[2]);
}
}
}
import java.util.Arrays;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
while(cin.hasNextDouble()){
double x = cin.nextDouble();
double y = cin.nextDouble();
double a = cin.nextDouble();
double b = cin.nextDouble();
double dis = (x - a) * (x - a) + (y - b) * (y - b);
dis = Math.sqrt(dis);
System.out.println(String.format("%.2f", dis));
}
}
}
import java.util.Arrays;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
while(cin.hasNextDouble()){
double r = cin.nextDouble();
double pi = Math.acos(-1.0);
double ans = pi * r * r * r * 4.0 / 3.0;
System.out.println(String.format("%.3f", ans));
}
}
}
import java.util.Arrays;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
while(cin.hasNextDouble()){
double ans = cin.nextDouble();
if(ans < 0){
ans = -ans;
}
System.out.println(String.format("%.2f", ans));
}
}
}
import java.util.Arrays;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
while(cin.hasNextInt()){
int x = cin.nextInt();
if(x >=90 && x <= 100){
System.out.println("A");
}else if(x >=80 && x < 90){
System.out.println("B");
}else if(x >=70 && x < 80){
System.out.println("C");
}else if(x >=60 && x <70){
System.out.println("D");
}else if(x >= 0 && x <= 60){
System.out.println("E");
}else {
System.out.println("Score is error!");
}
}
}
}
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
while(cin.hasNextInt()){
int t = cin.nextInt();
long ans = 1;
int x;
for(int i = 0; i < t; i++){
x = cin.nextInt();
if(x % 2 == 1){
ans = ans * x;
}
}
System.out.println(ans);
}
}
}
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
while(cin.hasNextInt()){
int x = cin.nextInt();
int y = cin.nextInt();
int a = 0;
int b = 0;
if(x > y){
int t = x;
x = y;
y = t;
}
for(int i = x; i <= y; i++){
if(i % 2 == 1){
a += i * i * i;
}
else {
b += i * i;
}
}
System.out.println(b + " " + a);
}
}
}
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
while(cin.hasNextInt()){
int t = cin.nextInt();
if(t == 0) {
break;
}
double x;
int a = 0, b = 0, c = 0;
for(int i = 0; i < t; i ++){
x = cin.nextDouble();
if(x < 0){
a ++;
}
else if(x == 0){
b ++;
}
else{
c ++;
}
}
System.out.println(a + " " + b + " " + c);
}
}
}
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
while(cin.hasNextDouble()){
double x = cin.nextDouble();
int y = cin.nextInt();
double ans = 0;
for(int i = 0; i < y; i++){
ans += x;
x = Math.sqrt(x);
}
System.out.println(String.format("%.2f", ans));
}
}
}
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
while(cin.hasNextInt()){
int l = cin.nextInt();
int r = cin.nextInt();
int num = 0;
int[] cnt = new int[1000];
for(int i = l; i <= r; i++){
int a = i % 10;
int c = i / 100;
int b = (i / 10) % 10;
if(a * a * a + b * b * b + c * c * c == i){
cnt[num++] = i;
}
}
if(num == 0) {
System.out.println("no");
}
else{
for(int i = 0; i < num-1; i++){
System.out.print(cnt[i] + " ");
}
System.out.println(cnt[num-1]);
}
}
}
}
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
while(cin.hasNextInt()){
int t = cin.nextInt();
while(t > 0){
int x = cin.nextInt();
double ans = 0;
for(int i = 1; i <= x; i++){
if(i % 2 == 0){
ans -= 1.0 / i;
}
else{
ans += 1.0 / i;
}
}
System.out.println(String.format("%.2f", ans));
t--;
}
}
}
}
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
while(cin.hasNextInt()){
int l = cin.nextInt();
int r = cin.nextInt();
if(l == 0 && r == 0){
break;
}
boolean check = true;
for(int i = l; i <= r; i++){
int s = i * i + i + 41;
boolean flag = true;
for(int j = 2; j < s; j++){
if(s % j == 0){
flag = false;
//System.out.println(s + "!!!!!!" + j);
break;
}
}
if(!flag){
check = false;
}
}
if(check){
System.out.println("OK");
}
else {
System.out.println("Sorry");
}
}
}
}
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
while(cin.hasNext()){
int n = cin.nextInt();
int sum = 1;
for(int i = 0; i < n-1; i++){
sum = (sum + 1) * 2;
}
System.out.println(sum);
}
}
}
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
while(cin.hasNextInt()){
int t = cin.nextInt();
int[] a = new int[110];
int maxx = -1, minn = 0x3f3f3f3f, sum = 0;
for(int i = 0; i < t; i ++){
a[i] = cin.nextInt();
sum += a[i];
maxx = Math.max(a[i], maxx);
minn = Math.min(a[i], minn);
}
sum -= maxx;
sum -= minn;
//System.out.println(sum + " !!!!!! " + t-2);
double ans = sum / (t - 2.0);
System.out.println(String.format("%.2f", ans));
}
}
}
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
while(cin.hasNextInt()){
int n = cin.nextInt();
int m = cin.nextInt();
int l = 2, r = 2 + 2 * (n-1);
int[] ans = new int[110];
int cnt = 0;
boolean flag = true;
if(n % m != 0) flag = false;
int tot = n / m;
for(int i = 0; i < tot; i++){
int sum = 0;
for(int j = 0; j < m; j++){
sum += l; l += 2;
}
ans[cnt++] = sum / m;
}
if(!flag){
int num = 0, sum = 0;
for(int i = l; i <= r; i += 2){
sum += i; num++;
}
ans[cnt++] = sum/num;
}
for(int i = 0; i < cnt - 1; i++){
System.out.print(ans[i] + " ");
}
System.out.println(ans[cnt-1]);
}
}
}
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
while(cin.hasNextInt()){
int T = cin.nextInt();
if(T == 0) break;
int[] a = new int[110];
int t, minn = 0x3f3f3f3f, x, id = -1;
for(int i = 0; i < T; i++){
x = cin.nextInt();
a[i] = x;
if(x < minn){
minn = x;
id = i;
}
}
t = a[0];
a[0] = minn;
a[id] = t;
for(int i = 0; i < T-1; i ++){
System.out.print(a[i] + " ");
}
System.out.println(a[T-1]);
}
}
}
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
int T = cin.nextInt();
String tes = cin.nextLine();
for(int t = 0; t < T; t++){
String s = cin.nextLine();
int num = 0;
int len = s.length();
for(int i = 0; i < len; i++){
char str = s.charAt(i);
if(str >= '0' && str <= '9') num ++;
}
System.out.println(num);
}
}
}
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
while(cin.hasNextInt()){
int n = cin.nextInt();
if (n == 0) break;
int[] dp = new int[100];
dp[0] = dp[1] = 1; dp[2] = 2; dp[3] =3; dp[4] = 4;
for(int i = 5; i <= n; i++){
dp[i] = dp[i-3] + dp[i-1];
}
System.out.println(dp[n]);
}
}
}
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
while(cin.hasNextInt()){
int n = cin.nextInt();
int m = cin.nextInt();
if(n == 0 && m == 0) break;
int[] a = new int[110];
int[] b = new int[110];
for(int i = 0; i < n; i++){
a[i] = cin.nextInt();
}
int id = n;
for(int i = 0; i < n; i++){
if(a[i] > m){
id = i;
break;
}
}
for(int i = 0; i < id; i++){
b[i] = a[i];
}
b[id] = m;
for(int i = id; i < n; i++){
b[i+1] = a[i];
}
for(int i = 0; i < n; i++){
System.out.print(b[i] + " ");
}
System.out.println(b[n]);
}
}
}
import java.util.Scanner;
public class Main{
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
while(cin.hasNext()){
int n = cin.nextInt();
if (n == 0) break;
if (n <= 100){
int arr[] = new int[n];
int temp = 0;
for(int j = 0; j <= arr.length-1; j++)
arr[j]=cin.nextInt();
for(int i = 0; i < arr.length-1; i++){
for(int j = 0;j<arr.length-1-i;j++){
if (Math.abs(arr[j])<Math.abs(arr[j+1])) {
temp=arr[j+1];
arr[j+1]=arr[j];
arr[j]=temp;
}
}
}
for(int i = 0;i<=arr.length-1;i++){
if (i==arr.length-1) {
System.out.println(arr[i]);
break;
}
System.out.print(arr[i]+" ");
}
}
}
}
}
import java.util.Scanner;
public class Main {
public static int Solve(int n) {
int ans = 0;
ans += n / 100; n %= 100;
ans += n / 50; n %= 50;
ans += n / 10; n %= 10;
ans += n / 5; n %= 5;
ans += n / 2; n %= 2;
ans += n;
return ans;
}
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
while(cin.hasNextInt()) {
int n = cin.nextInt();
if(n == 0) break;
int[] a = new int[110];
int sum = 0;
for(int i = 0; i < n; i++) {
a[i] = cin.nextInt();
sum += Solve(a[i]);
}
System.out.println(sum);
}
}
}
import java.util.Scanner;
class Main {
public static class Node{
int x, y, val, num;
}
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
while(cin.hasNextInt()) {
int n = cin.nextInt();
int m = cin.nextInt();
int maxx = -1, id = 0, ans = -1;
Node[] p = new Node[1100];
for(int i = 0; i < 1100; i ++){
p[i] = new Node();
}
int[][] a = new int[1100][1100];
for(int i = 0; i < n; i ++){
for(int j = 0; j < m; j ++){
a[i][j] = cin.nextInt();
p[id].num = a[i][j];
p[id].val = Math.abs(a[i][j]);
p[id].x = i + 1; p[id].y = j + 1;
if(maxx < p[id].val){
maxx = p[id].val;
ans = id;
}
id++;
}
}
System.out.println(p[ans].x + " " + p[ans].y + " " + p[ans].num);
}
}
}
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
while(cin.hasNextInt()){
int n = cin.nextInt();
int m = cin.nextInt();
int[][] a = new int[50][10];
double[] l = new double[50];
double[] r = new double[5];
for(int i = 0; i < n; i++){
for(int j = 0; j < m; j ++){
a[i][j] = cin.nextInt();
}
}
for(int i = 0; i < n; i++){
for(int j = 0; j < m; j++){
l[i] += a[i][j];
}
l[i] /= m;
if(i < n-1)
System.out.printf("%.2f ",l[i]);
else
System.out.printf("%.2f\r\n",l[i]);
}
for(int i = 0 ; i < m; i++){
for(int j = 0; j < n; j++){
r[i] += a[j][i];
}
r[i] /= n;
if(i < m-1)
System.out.printf("%.2f ",r[i]);
else
System.out.printf("%.2f\r\n",r[i]);
}
int cnt = 0;
for(int i = 0; i < n; i++){
boolean flag = true;
for(int j = 0; j < m; j++){
if(a[i][j] < r[j]){
flag = false;
break;
}
}
if(flag)
cnt += 1;
}
System.out.printf("%d\r\n\r\n",cnt);
}
}
}
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
int T = cin.nextInt();
String tes = cin.nextLine();
while(T > 0){
String s = cin.nextLine();
boolean flag = true;
char str = s.charAt(0);
if((str>='0'&&str<='9')) flag = false;
int len = s.length();
for(int i = 0; i < len; i++){
str = s.charAt(i);
if((str>='0'&&str<='9') || (str=='_') || (str>='a'&&str<='z') || (str>='A'&&str<='Z'))
continue;
else{
flag = false; break;
}
}
if(flag) System.out.println("yes");
else System.out.println("no");
T--;
}
}
}
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
while(cin.hasNext()){
char str = 'a';
String s = cin.nextLine();
char[] a = s.toCharArray();
int len = s.length();
for(int i = 0; i < len; i++){
if(str < a[i]) str = a[i];
}
for (int i = 0; i < len; i++){
System.out.print(a[i]);
if(a[i] == str) System.out.print("(max)");
}
System.out.println();
}
}
}
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
while(cin.hasNext()){
String s = cin.nextLine();
char[] str = s.toCharArray();
int len = s.length();
str[0] -= 32;
System.out.print(str[0]);
for(int i = 1; i < len; i++){
if(str[i-1] == ' ') str[i] -= 32;
System.out.print(str[i]);
}
System.out.println();
}
}
}
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
int T = cin.nextInt();
String temp = cin.nextLine();
while(T-- > 0){
String str = cin.nextLine();
char[] s = str.toCharArray();
int len = str.length();
int a = 0, e = 0, i = 0, o = 0, u = 0;
for(int j = 0; j < len; j++){
if(s[j] == 'a') a ++;
else if(s[j] == 'e') e ++;
else if(s[j] == 'i') i ++;
else if(s[j] == 'o') o ++;
else if(s[j] == 'u') u ++;
}
System.out.println("a:" + a);
System.out.println("e:" + e);
System.out.println("i:" + i);
System.out.println("o:" + o);
System.out.println("u:" + u);
if(T > 0)
System.out.println();
}
}
}
HDU - 2028 Lowest Common Multiple Plus
import java.util.*;
import java.math.*;
import java.io.*;
public class Main{
public static long gcd(long a, long b){
return b == 0 ? a : gcd(b, a % b);
}
public static long lcm(long a, long b){
return a * b / gcd(a, b);
}
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
while(cin.hasNext()){
int n = cin.nextInt();
long ans = 1;
long[] a = new long[n+1];
for(int i = 0; i < n; i++){
a[i] = cin.nextLong();
ans = lcm(ans, a[i]);
}
System.out.println(ans);
}
}
}
HDU - 2029 Palindromes _easy version
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
int T = cin.nextInt();
String temp = cin.nextLine();
while(T-- > 0){
String str = cin.nextLine();
char[] s = str.toCharArray();
int len = str.length();
boolean flag = true;
for(int i = 0; i < len / 2; i++){
if(s[i] != s[len-1-i]){
flag = false; break;
}
}
if(flag) System.out.println("yes");
else System.out.println("no");
}
}
}
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
int T = cin.nextInt();
cin.nextLine();
while(T-- > 0){
String s = cin.nextLine();
int cnt = 0;
byte[] a = s.getBytes();
int len = a.length;
for(int i = 0; i < len; i++){
if(a[i] < 0) cnt++;
}
System.out.println(cnt/2);
}
}
}
import java.lang.reflect.Array;
import java.util.*;
import java.math.*;
import java.io.*;
public class Main{
public static String reverse1(String str){
return new StringBuilder(str).reverse().toString();
}
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
char[] blog = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
while(cin.hasNext()){
int n = cin.nextInt();
int m = cin.nextInt();
boolean flag = true;
if(n < 0) {
flag = false;
n = -n;
}
if(n == 0) {
System.out.println("0");
continue;
}
int len = 0;
char[] s = new char[110];
while(n >= m){
s[len++] = blog[n%m];
n /= m;
}
if(n != 0) s[len++] = blog[n];
if(!flag) System.out.print("-");
for(int i = len-1; i > 0; i--) System.out.print(s[i]);
System.out.println(s[0]);
}
}
}
import java.util.*;
import java.io.*;
import java.math.*;
public class Main{
public static void main(String[] args){
Scanner cin = new Scanner(System.in);
int[][] mp = new int[35][35];
for(int i = 0; i < 35; i++) {
mp[0][i] = 0;
mp[i][0] = 0;
mp[i][i] = 1;
mp[i][1] = 1;
}
for(int i = 3; i < 35; i++){
for(int j = 2; j < i; j++){
mp[i][j] = mp[i-1][j] + mp[i-1][j-1];
}
}
while(cin.hasNext()){
int n = cin.nextInt();
for(int i = 1; i <= n; i++){
for(int j = 1; j < i; j++){
System.out.print(mp[i][j] + " ");
}
System.out.println(mp[i][i]);
}
System.out.println();
}
}
}
import java.util.*;
import java.io.*;
import java.math.*;
public class Main{
public static void main(String[] args){
Scanner cin = new Scanner(System.in);
int T = cin.nextInt();
while(T-- > 0){
int a = cin.nextInt();
int b = cin.nextInt();
int c = cin.nextInt();
int x = cin.nextInt();
int y = cin.nextInt();
int z = cin.nextInt();
int t1 = a * 60 * 60 + b * 60 + c;
int t2 = x * 60 * 60 + y * 60 + z;
int t = t1 + t2;
int p = t / (60 * 60);
t %= (60 * 60);
int q = t / 60;
t %= 60;
System.out.println(p + " " + q + " " + t);
}
}
}
import java.util.*;
import java.io.*;
import java.math.*;
public class Main{
public static void main(String[] args){
Scanner cin = new Scanner(System.in);
while(cin.hasNext()){
int n = cin.nextInt();
int m = cin.nextInt();
if(n == 0 && m == 0) break;
int[] a = new int[n];
int[] b = new int[m];
int[] c = new int[n];
for(int i = 0; i < n; i++) a[i] = cin.nextInt();
for(int i = 0; i < m; i++) b[i] = cin.nextInt();
int num = 0;
for(int i = 0; i < n; i++) {
boolean flag = false;
for(int j = 0; j < m; j++){
if(a[i] == b[j]){
flag = true;
break;
}
}
if(!flag){
c[num++] = a[i];
}
}
int cnt = 0;
Arrays.sort(c);
if(num == 0) System.out.println("NULL");
else{
for(int i = 0; i < n; i++){
int x = c[i];
for(int j = 0; j < n; j++){
if(x == a[j]){
cnt++;
if(cnt == num) System.out.println(x + " ");
else System.out.print(x + " ");
}
}
}
}
}
}
}
import java.io.*;
import java.math.*;
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
while(cin.hasNext()){
int a = cin.nextInt();
int b = cin.nextInt();
if(a == 0 && b == 0)
break;
int ans = 1;
for(int i = 0; i < b; i++){
ans = ans * a;
ans %= 1000;
}
System.out.println(ans);
}
}
}
import java.io.*;
import java.math.*;
import java.util.*;
public class Main {
public static double Get_area(double x0, double y0, double x1,double y1, double x2,double y2){
return (x0*y1 + x2*y0 + x1*y2 - x2*y1 - x0*y2 - x1*y0 ) / 2.0;
}
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
while(cin.hasNext()){
int n = cin.nextInt();
if (n == 0) break;
double[] x = new double[n];
double[] y = new double[n];
for(int i = 0; i < n; i++){
x[i] = cin.nextDouble();
y[i] = cin.nextDouble();
}
double sum = 0.0;
for(int i = 1; i < n-1; i++){
sum += Get_area(x[0], y[0], x[i], y[i], x[i+1], y[i+1]);
}
System.out.println(sum);
}
}
}
import java.io.*;
import java.math.*;
import java.util.*;
public class Main {
public static class Node{
int l, r;
}
public static class cmp implements Comparator<Node>{
public int compare(Node a, Node b){
if(a.r > b.r) return 1;
else if(a.r < b.r) return -1;
else return 0;
}
}
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
while(cin.hasNext()){
int n = cin.nextInt();
if (n == 0) break;
Node[] p = new Node[n];
for(int i = 0; i < n; i++) p[i] = new Node();
for(int i = 0; i < n; i++){
p[i].l = cin.nextInt();
p[i].r = cin.nextInt();
}
Arrays.sort(p, new cmp());
int sum = 1, pre = p[0].r;
for(int i = 1; i < n; i++){
if(p[i].l >= pre) {
pre = p[i].r;
sum++;
}
}
System.out.println(sum);
}
}
}
import java.io.*;
import java.math.*;
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
int T = cin.nextInt();
while(T-- > 0){
double[] a = new double[3];
for(int i = 0; i < 3; i++){
a[i] = cin.nextDouble();
}
Arrays.sort(a);
if(a[0] + a[1] > a[2])
System.out.println("YES");
else
System.out.println("NO");
}
}
}
import java.io.*;
import java.math.*;
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
int T = cin.nextInt();
while(T-- > 0){
long a = cin.nextLong();
long b = cin.nextLong();
long an = 0, bn = 0;
for(int i = 2; i*i <= a; i++){
if(a % i == 0){
if(a / i == i) an += i;
else {
an += i;
an += (a / i);
//System.out.println(i + " " + a/i);
}
}
}
for(int i = 2; i*i <= b; i++){
if(b % i == 0){
if(b / i == i) bn += i;
else {
bn += i;
bn += (b / i);
}
}
}
//System.out.println(an + "!!!" + bn);
if(an == b-1 && bn == a-1)
System.out.println("YES");
else System.out.println("NO");
}
}
}
import java.io.*;
import java.math.*;
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
int[] a = new int[45];
a[0] = 0; a[1] = 1; a[2] = 1;
for(int i = 3; i < 45; i++){
a[i] = a[i-1] + a[i-2];
}
int T = cin.nextInt();
while(T-- > 0){
int n = cin.nextInt();
System.out.println(a[n]);
}
}
}
import java.io.*;
import java.math.*;
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
int T = cin.nextInt();
int[] a = new int[40];
a[0] = 3;
for(int i = 1; i < 40; i++){
a[i] = (a[i-1] - 1) * 2;
}
while(T-- > 0){
int n = cin.nextInt();
System.out.println(a[n]);
}
}
}
import java.io.*;
import java.math.*;
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
int T = cin.nextInt();
String ssss = cin.nextLine();
while(T-- > 0){
String s = cin.nextLine();
int len = s.length();
int a = 0, b = 0, c = 0, d = 0;
for(int i = 0; i < len; i++){
if(s.charAt(i) >= '0' && s.charAt(i) <= '9') a = 1;
else if(s.charAt(i) >= 'a' && s.charAt(i) <= 'z') b = 1;
else if (s.charAt(i) >= 'A' && s.charAt(i) <= 'Z') c = 1;
else if(s.charAt(i) == '^' || s.charAt(i) == '~' || s.charAt(i) == '!' || s.charAt(i) == '@' || s.charAt(i) == '#' || s.charAt(i) == '$' || s.charAt(i) == '%') d = 1;
}
if(a + b + c + d >= 3 && len >= 8 && len <= 16)
System.out.println("YES");
else System.out.println("NO");
}
}
}
import java.io.*;
import java.math.*;
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
long[] dp = new long[55];
dp[0] = 0; dp[1] = 1;
dp[2] = 1;
for(int i = 3; i < 55; i++){
dp[i] = dp[i-1] + dp[i-2];
}
int T = cin.nextInt();
while(T-- > 0){
int a = cin.nextInt();
int b = cin.nextInt();
b = b - a + 1;
System.out.println(dp[b]);
}
}
}
HDU - 2045 不容易系列之(3)—— LELE的RPG难题
import java.io.*;
import java.math.*;
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
long[] dp = new long[55];
dp[0] = 3; dp[1] = 3; dp[2] = 6; dp[3] = 6;
for(int i = 4; i < 55; i++) dp[i] = dp[i-1] + 2*dp[i-2];
while(cin.hasNext()){
int n = cin.nextInt();
System.out.println(dp[n]);
}
}
}
import java.io.*;
import java.math.*;
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
long[] dp = new long[55];
dp[0] = 1; dp[1] = 1; dp[2] = 2; dp[3] = 3;
for(int i = 4; i < 55; i++) dp[i] = dp[i-1] + dp[i-2];
while(cin.hasNext()){
int n = cin.nextInt();
System.out.println(dp[n]);
}
}
}
import java.io.*;
import java.math.*;
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
long[] dp = new long[55];
dp[0] = 1; dp[1] = 3; dp[2] = 8; dp[3] = 22;
for(int i = 4; i < 55; i++) dp[i] = (dp[i-1] + dp[i-2]) * 2;
while(cin.hasNext()){
int n = cin.nextInt();
System.out.println(dp[n]);
}
}
}
import java.io.*;
import java.math.*;
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
double[][] dp = new double[21][2];
dp[1][0] = 1; dp[1][1] = 0; dp[2][0] = 2; dp[2][1] = 1;
for(int i = 3; i < 21; i++){
dp[i][0] = i * dp[i-1][0];
dp[i][1] = (i-1) * (dp[i-1][1] + dp[i-2][1]);
}
int T = cin.nextInt();
while(T-- > 0){
int n = cin.nextInt();
double ans = 100.0 * dp[n][1] / dp[n][0];
System.out.printf("%.2f", ans);
System.out.println("%");
}
}
}