poj 2509 Peter's smokes - タバコは控えめに
2007/10/13
java
poj
2509 -- Peter's smokes
POJ 2509 Peter's smokes - 路雪军 Carl - CSDNBlog
実はこの問題の意味がわかってないです。Orz...
簡単だとは思うのですが...
package p2509_ref;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
while (scanner.hasNext()) {
int n = scanner.nextInt();
int k = scanner.nextInt();
System.out.println(f(n,k));
}
}
static long f(int n, int k){
long sum = n;
int a = n;
for(;k <= a;){
sum += a / k;
a = (a / k) + (a % k);
}
return sum;
}
}
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
while (scanner.hasNext()) {
int n = scanner.nextInt();
int k = scanner.nextInt();
System.out.println(f(n,k));
}
}
static long f(int n, int k){
long sum = n;
int a = n;
for(;k <= a;){
sum += a / k;
a = (a / k) + (a % k);
}
return sum;
}
}
: