题解分享
题解分享简介
星期计算(结果填空) - 题解
```
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
typedef long long ll;
using namespace std;
int main(){
ll tianshu=1 ;
for(int i=1;i<=22;i++){
tianshu*=20;
tianshu%=7;
}
int dayIn=6;
int res=(6+tianshu-1)%7+1;cout<<res;
}
```
查看全文
0
0
1
1
星期计算(结果填空) - 题解
```
public class Main {
public static void main(String[] args) {
int now=6;
// 可以进行适当的化简
// 我们发现(20*20)%7=1
// (20)^22变成了(1)^11
// 于是结果为 1+6=7
System.out.println(1+now);
// 正常做法
// int res = 20;
// for(int i=1;i<22;i++) {
// res*=20;
// res=res%7;
// }
// System.out.println(res+now);
}
}
```
查看全文
0
0
1
1
星期计算(结果填空) - 题解
```
#include<bits/stdc++.h>
using namespace std;
int main(){
int res=1;
int currentDay=6;
for(int i = 1;i <= 22;i++){
res = (res%7)*20%7;
}
int nextDay=(currentDay+res - 1)%7 + 1;
cout<<nextDay<<endl;
}
```
查看全文
0
0
0
2
星期计算(结果填空) - 题解
```
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
using ll = long long;
using ULL = unsigned long long;
const int N = 1e6+5;
int power(int a,int b,int p){
int ans = 1 % p;
for(; b; b >>= 1){
if(b & 1) ans = ans * a % p;
a = a * a % p;
}
return ans;
}
inline void solve() {
cout << power(20,22,7) + 6;
}
int main() {
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int _ = 1;
//int _; cin >> _;
while (_--) solve();
return 0;
}
```
查看全文
0
0
0
1
星期计算(结果填空) - 题解
include
using namespace std;
define endl '\n'
using ll = long long;
ll power(ll a, int b, int mod){
ll ans = 1;
while(b > 0){
if((b & 1 == 1)){
ans = (ans a) % mod;
}
a = (a a) % mod;
b >>= 1;
}
return ans;
}
int main() {
int cur = 6;
ll day = power(20, 22, 7);
int fut = (cur + day) % 7;
if(fut == 0){
fut = 7;
}
cout << fut << endl;
return 0;
}
查看全文
0
0
0
1
星期计算(结果填空) - 题解
```
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
long long ans=1;
for(int i=1;i<=2;i++){
ans=(ans*20)%7;
}//经过了几天
int day=6;
for(int i=1;i<=ans;i++){
day++;
if(day==8) day=1;
}
cout<<day;
return 0;
}
```
查看全文
0
0
0
2
星期计算(结果填空) - 题解
2020%7=1
202020%7=6
20202020%7=1
2020202020%7=6
//偶1,奇6,结果加个6
0
0
0
1
星期计算(结果填空) - 题解
```
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
//20^22数据过于大,用循环来做
int main()
{
int a=20,b=22,c=1;
for(int i=1;i<=b;i++) //b次循环每次乘a
{
c*=a; //存储每次a的值再取模
c%=7;
}
cout<<c+6<<endl; //加上一开始的星期六
return 0;
}
```
查看全文
0
0
0
1
星期计算(结果填空) - 题解
```cpp
#include <iostream>
using namespace std;
int main()
{
int res = 6, n = 1;
for (int i = 0; i < 22; i++)
{
n *= 20;
n %= 7;
}
cout << (res + n - 1) % 7 + 1;
return 0;
}
```
res 存结果,当前为周六,n 存 20^22 的值
n乘22次20,每次模7
最后打印当前是周几
查看全文
0
0
0
1



