SPOJ Problem 1112:Number Steps

水题,验证压代码能力。。。

#include<cstdio>
#include<cstring>
int main(){
    int n,x,y;
    scanf("%d",&n);
    while(n--){
        scanf("%d%d",&x,&y);
        if (x!=y&&x-2!=y)
            printf("No Number\n");
        else
            printf("%d\n",x+y-(y&1));
    }
}
时间: 2024-10-19 23:10:36

SPOJ Problem 1112:Number Steps的相关文章

素数筛法--SPOJ Problem 2 Prime Generator

质数(prime number)又称素数,除了1和它本身外,不能整除以其他自然数,换句话说就是该数除了1和它本身以外不再有其他的因数:否则称为合数.最小的质数是2. 要判断一个整数N是不是质数很简单,看它是否能被2到sqrt(N)之间的整数整除即可. def isPrime(n): if n%2==0: return False for i in xrange(3,int(math.sqrt(n)+1),2): if n%i==0: return False return True 不过要找出1

杭电 HDU ACM 1391 Number Steps

Number Steps Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 4376    Accepted Submission(s): 2656 Problem Description Starting from point (0,0) on a plane, we have written all non-negative inte

Number Steps

Number Steps Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 4482    Accepted Submission(s): 2732 Problem Description Starting from point (0,0) on a plane, we have written all non-negative integ

FZU Problem 1853 Number Deletion

Problem 1853 Number Deletion Accept: 80    Submit: 239 Time Limit: 1000 mSec    Memory Limit : 32768 KB  Problem Description Given you one n-digital positive integer a,After removing any of them k( k < n) digits, the remaining figures form a new posi

SPOJ MYQ10 Mirror Number 数位dp&#39;

题目链接:点击打开链接 MYQ10 - Mirror Number A number is called a Mirror number if on lateral inversion, it gives the same number i.e it looks the same in a mirror. For example 101 is a mirror number while 100 is not. Given two numbers a and b, find the number

SPOJ Problem 7974:What&#39;s Next

求数列下一项,啥都不说了,贡献了N多WA... #include<cstdio> int main(){ int a,b,c; while(scanf("%d%d%d",&a,&b,&c)&&(a||b||c)){ if (b*2==c+a&&b!=a) printf("AP %d\n",2*c-b); else printf("GP %d\n",c*c/b); } return

Problem Single Number

Problem Description: Given an array of integers, every element appears twice except for one. Find that single one. Solution: 1 public int singleNumber(int[] A) { 2 Arrays.sort(A); 3 for (int i = 1; i < A.length; i += 2) { 4 if (A[i-1] != A[i]) { 5 re

Problem Single Number II

Problem Description: Given an array of integers, every element appears three times except for one. Find that single one. Solution: 1 Arrays.sort(A); 2 for (int i = 2; i < A.length; i += 3) { 3 if (A[i] != A[i-2]) { 4 return A[i-2]; 5 } 6 } 7 8 return

【SPOJ】NUMOFPAL - Number of Palindromes(Manacher,回文树)

[SPOJ]NUMOFPAL - Number of Palindromes(Manacher,回文树) 题面 洛谷 求一个串中包含几个回文串 题解 Manacher傻逼题 只是用回文树写写而已.. #include<iostream> #include<cstdio> #include<cstdlib> #include<cstring> #include<cmath> #include<algorithm> #include<