参考代码:
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int a = scanner.nextInt(); int b = scanner.nextInt(); String []week = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}; //System.out.println(week[binEmod1(a, b, 7)]); System.out.println(week[binEmod2(a, b, 7)]); } public static int binEmod1(int a, int b, int m) { int res = 1; while(b > 0) { if((b & 1) == 1) res = res * a % m; a = a * a % m; b >>= 1; } return res; } public static int binEmod2(int a, int b, int m) { if(b == 0) return 1; int res = binEmod1(a, b >> 1, m); return ((b & 1) == 1) ? res * res * a % m : res * res % m; } }
0.0分
5 人评分
C语言程序设计教程(第三版)课后习题8.6 (C语言代码)浏览:612 |
C语言程序设计教程(第三版)课后习题5.8 (C语言代码)浏览:613 |
C语言程序设计教程(第三版)课后习题6.5 (C++代码)浏览:487 |
【绝对值排序】 (C语言代码)浏览:894 |
1128题解(返回值为数组的情况)浏览:571 |
【魔板】 (C++代码)浏览:1238 |
C语言程序设计教程(第三版)课后习题7.3 (C语言代码)浏览:555 |
马拦过河卒 (C语言代码)浏览:1213 |
简单的a+b (C语言代码)浏览:538 |
很简单,,题解1041:C语言程序设计教程(第三版)课后习题9.8 (C语言代码)浏览:616 |