import java.util.Scanner;
public class C022 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
while (in.hasNext()) {
int t = in.nextInt();
for(int r = 0; r < t; r++){
int a = in.nextInt();
int b = in.nextInt();
int c = 0;
if(a == b){
if((a%2)==1)
System.out.println("case "+ (r+1) + ": " + a);
else
System.out.println("case "+ (r+1) + ": 0");
}
else{
while(a <= b){
if((a%2)==1){
c += a;
a += 2;
}
else{
a++;
c += a;
a += 2;
}
}
System.out.println("case "+ (r+1) + ": " +c);
}
}
}
}
}
請問一下 為什麼會RE? 在讀取格式上是有漏掉什麼嗎?
import java.util.Scanner;
public class C022 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
while (in.hasNext()) {
int t = in.nextInt();
for(int r = 0; r < t; r++){
int a = in.nextInt();
int b = in.nextInt();
int c = 0;
if(a == b){
if((a%2)==1)
System.out.println("case "+ (r+1) + ": " + a);
else
System.out.println("case "+ (r+1) + ": 0");
}
else{
while(a <= b){
if((a%2)==1){
c += a;
a += 2;
}
else{
a++;
c += a;
a += 2;
}
}
System.out.println("case "+ (r+1) + ": " +c);
}
}
}
}
}
請問一下 為什麼會RE? 在讀取格式上是有漏掉什麼嗎?
我也是用JAVA寫...
也一直RE...
有神人用JAVA寫過的嗎?0.0
import java.util.Scanner;
public class C022 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
while (in.hasNext()) {
int t = in.nextInt();
for(int r = 0; r < t; r++){
int a = in.nextInt();
int b = in.nextInt();
int c = 0;
if(a == b){
if((a%2)==1)
System.out.println("case "+ (r+1) + ": " + a);
else
System.out.println("case "+ (r+1) + ": 0");
}
else{
while(a <= b){
if((a%2)==1){
c += a;
a += 2;
}
else{
a++;
c += a;
a += 2;
}
}
System.out.println("case "+ (r+1) + ": " +c);
}
}
}
}
}
請問一下 為什麼會RE? 在讀取格式上是有漏掉什麼嗎?
我也是用JAVA寫...
也一直RE...
有神人用JAVA寫過的嗎?0.0
import java.util.Scanner;
public class C022 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
while (in.hasNext()) {
int t = in.nextInt();
for(int r = 0; r < t; r++){
int a = in.nextInt();
int b = in.nextInt();
int c = 0;
if(a == b){
if((a%2)==1)
System.out.println("case "+ (r+1) + ": " + a);
else
System.out.println("case "+ (r+1) + ": 0");
}
else{
while(a <= b){
if((a%2)==1){
c += a;
a += 2;
}
else{
a++;
c += a;
a += 2;
}
}
System.out.println("case "+ (r+1) + ": " +c);
}
}
}
}
}
請問一下 為什麼會RE? 在讀取格式上是有漏掉什麼嗎?
我也是用JAVA寫...
也一直RE...
有神人用JAVA寫過的嗎?0.0
AC了...
把while拿掉試試看...