解题思路:
注意事项:
参考代码:
1.
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
long n=scanner.nextInt();
long k=scanner.nextInt();
long t=scanner.nextInt();
long sum=1;
long m=1;
long a1=1;
long i=1;
while(i<t) {
long sn=a1*n+(n*(n-1)/2;
m=(m+sn)%k;
a1+=n;
sum+=m;
i++;
}
System.out.println(sum);
}
}
2.
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
long n=scanner.nextInt();
long k=scanner.nextInt();
long t=scanner.nextInt();
long sum=1;
long m=1;
long a1=1;
long i=1;
while(i<t) {
long an=a1+(n-1);
long sn=(a1+an)*n/2;
m=(m+sn)%k;
a1+=n;
sum+=m;
i++;
}
System.out.println(sum);
}
}
0.0分
0 人评分
C语言训练-求PI* (C语言代码)(正确结果竟然是谜一样的3.141591)浏览:1339 |
C语言训练-计算1977!* (C语言代码)浏览:941 |
C语言程序设计教程(第三版)课后习题10.2 (C语言代码)浏览:689 |
兰顿蚂蚁 (C++代码)浏览:1160 |
C二级辅导-同因查找 (C语言代码)浏览:618 |
输出九九乘法表 (C语言代码)浏览:1172 |
C语言程序设计教程(第三版)课后习题1.6 (C语言代码)浏览:692 |
A+B for Input-Output Practice (IV) (C语言代码)浏览:529 |
母牛的故事 (C语言代码)浏览:625 |
神奇的fans (C语言代码)浏览:1125 |