1. 程式人生 > 實用技巧 >2020十一屆藍橋杯-七月省賽

2020十一屆藍橋杯-七月省賽


兩種做法

#include <stdio.h>
#include <iostream>
using namespace std;

int dfs(int n) {
	if (n == 1)
		return 7;
	else if (n % 2 == 0) {
		return (dfs(n / 2) * dfs(n / 2)) % 1921;
	}
	else {
		return (dfs(n / 2) * dfs(n / 2) * 7) % 1921;
	}
}

int main() {
	cout << dfs(2020);
	return 0;
}
#include <stdio.h>
#include <iostream>
#include <map>
using namespace std;

int main() {
	int ans = 1;
	for (int i = 1; i <= 2020; i++) {
		ans = (ans * 7) % 1921;
	}
	cout << ans;

	return 0;
}

第二題

#include <stdio.h>
#include <iostream>
#include <map>
using namespace std;
int main() {
	
	string str = "EaFnjISplhFviDhwFbEjRjfIBBkRyY";
	string old = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
	string New = "yxmdacikntjhqlgoufszpwbrevYXMDACIKNTJHQLGOUFSZPWBREV";
	int index = 0;
	for (int i = 0; i < str.size(); i++) {
		index = New.find(str[i]);
		cout << old[index];
	}

	return 0;
}

第三題

#include <stdio.h>
#include <iostream>
#include <map>
using namespace std;
int main() {
	
	int start = 1000;
	int flag = 1;// 1表示要跑
	int cnt = 0;
	while (start != 0) {
		if (flag) {
			if (start - 600 >= 0) {
				start -= 600;
				cnt += 60;
			}
			else {
				cnt += (start / 10);
				start = 0;
			}
			flag = !flag;
		}
		else {
			start += 300;
			cnt += 60;
			flag = !flag;
		}
		
	}

	cout << cnt;

	return 0;
}

D

E

F

G

H

I

J