each line, there is x, and y representing the coordinates (x, y) of a point.
For each point in the input, write the number written at that point or write No Number if there is none.
3 4 2 6 6 3 4
6 12 No Number
import java.util.Scanner;
public class Main{
public static void main(String[] args){
int N,x,y;
Scanner sc=new Scanner(System.in);
N=sc.nextInt();
for (int i=1;i<=N;i++){
x=sc.nextInt();
y=sc.nextInt();
if ((x-y==2)||(x-y==0)){
if (x%2==0){
System.out.println(x+y);
}
else {
System.out.println(x+y-1);
}
}
else {
System.out.println("No Number");
}
}
}
}
#include<iostream>
#include<vector>
using namespace std;
int main(){
int x,y;
while(cin>>x>>y){
if((x+y)%2==0){
if(y%2!=0){
cout<<x+y-1<<endl;
}else{
cout<<x+y<<endl;
}
}else{
cout<<"No Number"<<endl;
}
}
return 0;
} #include <bits/stdc++.h>
using namespace std;
bool isXY(int x,int y){
if(y==x||y==x-2)
return true;
else{
cout<<"No Number";
return false;
}
}
int main(){
int n,a[10000],b[10000],a0,b0,j=0,k=0,l=0,count,x,y;
for(int i=0;i<=11000;i++){
if(j==2){
b[k++]=i;
count++;
if(count!=2)
continue;
else{
j=0;
continue;
}
}
a[l++]=i;
j++;
count=0;
}
cin>>x>>y;
if(isXY(x,y)){
if(y==x){
cout<<a[x];
}
else {
cout<<b[x-2];
}
}
return 0;
}
#include<iostream>
#include<cstring>
using namespace std;
int main(){
int x,y;
while(cin>>x>>y){
if(x==y){
if(x%2==0)cout<<2*x<<endl;
else cout<<2*x-1<<endl;
}else if(y==x-2){
if((x-1)%2==0)cout<<2*(x-1)-1<<endl;
else cout<<2*(x-1)<<endl;
}else cout<<"No Number"<<endl;
}
return 0;
}
#include<iostream>
using namespace std;
int main(){
int x,y;
while(cin>>x>>y){
int answer=0;
if(x==y){
if(x%2==0)
answer=x*2;
else
answer=x*2-1;
cout<<answer<<"\n";
}
else if(y==x-2){
if(x%2==0)
answer=x*2-2;
else
answer=x*2-3;
cout<<answer<<"\n";
}
else
cout<<"No Number"<<"\n";
}
return 0;
} #include <stdio.h>
#define N 12000
int main()
{
int i, x, y, findit;
int a[N][2];//a[i][0]代表x,a[i][1]代表y
a[0][0]=0;
a[0][1]=0;
for(i=1; i<N; i++)
{
switch(i%4){
case 1:
a[i][0]=a[i-1][0]+1;
a[i][1]=a[i-1][1]+1;
break;
case 2:
a[i][0]=a[i-1][0]+1;
a[i][1]=a[i-1][1]-1;
break;
case 3:
a[i][0]=a[i-1][0]+1;
a[i][1]=a[i-1][1]+1;
break;
case 0:
a[i][0]=a[i-1][0]-1;
a[i][1]=a[i-1][1]+1;
break;
default: break;
}
}
while(scanf("%d %d", &x, &y)!=EOF)
{
findit=0;//表示没找到
for(i=0; i<N; i++)
{
if(x==a[i][0]&&y==a[i][1])
{
printf("%d\n", i);
findit=1;
break;
}
}
if(findit==0) printf("No Number\n");
}
return 0;
} #include <iostream>
using namespace std;
int main() {
int x,y;
while(cin>>x>>y){
if((x!=y&&x!=(y+2))||x<0||y<0){
cout<<"No Number"<<endl;
continue;
}
cout<<2*x-(x%2)-(x-y)<<endl;
}
} #n = int(input())
自测数据和提交数据不一样
a = 2
b = 0
c1 = 0
c = 0
#for i in range(n):
x, y = list(map(int, input().split()))
if x == 0 and y == 0:
print(0)
elif x == 2 and y == 0:
print(2)
elif x-2 == y:
while y:
y -= 1
c += 1
if c % 2 != 0:
a += 1
else:
a += 3
print(a)
elif x == y:
# y -= 1
while y:
y -= 1
c1 += 1
if c1 % 2 != 0:
b += 1
else:
b += 3
print(b)
else:
print("No Number")