1、3451:【例82.1】不吉利日期
不吉利的日期(PAT)
不吉利的日期(PAT)_在国外,每月的13号和每周的星期5都是不吉利的。特别是当13号那天恰好是星期5时,更-CSDN博客
OpenJudge NOI 1.13 02:不吉利日期
/*
1.13编程基础之综合应用_02不吉利日期01
http://noi.openjudge.cn/ch0113/02/
https://blog.csdn.net/ljf_study/article/details/76409549
*/
#include <stdio.h>
#include <iostream>
#include <stack>
#include <string.h>
#include <queue>
#include <cmath>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <string>
using namespace std;
typedef long long LL;
#define MAX 1001
int a[MAX][MAX];
int b[MAX][MAX];
int res[MAX][MAX];
int n, m;
int day[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int sumDay(int month)
{
int sumday = 0;
for(int i = 1; i < month; i++){
sumday += day[i];
}
sumday += 13;
return sumday;
}
int main() {
//freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
int n;
cin >> n;
for(int i = 1; i <= 12; i++){
if(((sumDay(i) - 1) % 7 + n) % 7 == 5){
cout << i << endl;
}
}
return 0;
}
/*
1.13编程基础之综合应用_02不吉利日期03
http://noi.openjudge.cn/ch0113/02/
https://blog.csdn.net/ljf_study/article/details/76409549
https://blog.csdn.net/tigerisland45/article/details/69791524
https://blog.csdn.net/Gnipuohz/article/details/8300563
*/
#include<stdio.h>
int main()
{
int day[13]={0,12,31,28,31,30,31,30,31,31,30,31,30};
int w;
int i;
scanf("%d",&w);
for(i=1;i<=12;i++)
{w=(w+day[i])%7;
if(w==5) printf("%d\n",i);
}
return 0;
}
/*
1.13编程基础之综合应用_02不吉利日期02
http://noi.openjudge.cn/ch0113/02/
https://blog.csdn.net/ljf_study/article/details/76409549
https://blog.csdn.net/tigerisland45/article/details/69791524
*/
/* Bailian2723 不吉利日期 */
#include <stdio.h>
#define DAYS 7
#define N 13
enum DAY {MON=1, TUE, WED, THU, FRI, SAT, SUN};
int days[]={31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int main(void)
{
int w, day, i;
scanf("%d", &w);
for(i=1; i<=12; i++) {
day = (w - 1 + N) % DAYS;
if(day == FRI)
printf("%d\n", i);
w = (w + days[i-1]) % DAYS;
}
return 0;
}
2、3452:【例82.2】 座次问题
【信息学奥赛一本通-编程启蒙】3452【例82.2】 座次问题
/*
3452:【例82.2】 座次问题
http://bas.ssoier.cn:8086/problem_show.php?pid=3452
*/
#include <bits/stdc++.h>
using namespace std;
int main( )
{
vector<string> M1;
vector<int> M2;
int N;
string name;
cin>>N;
for(int i=0;i<N;i++)
{
cin>>name;
M1.push_back(name);
M2.push_back(i);
}
do{
for( vector<int>::iterator it=M2.begin();it!=M2.end();it++){
cout<<M1[(*it)]<<" ";
}
cout<<endl;
}while(next_permutation(M2.begin(),M2.end()));
return 0;
}
3、3453:【例82.3】 公平抽签
【信息学奥赛一本通-编程启蒙】3453【例82.3】 公平抽签
组合数问题(公平抽签)
/*
3453:【例82.3】 公平抽签
http://bas.ssoier.cn:8086/problem_show.php?pid=3453
*/
#include <bits/stdc++.h>
using namespace std;
int n,m;
string a[20];
int main( )
{
cin>>n>>m;
for(int i=0;i<n;i++)
{
cin>>a[i];
}
int U=1<<n;
for(int S=0;S<U;S++)
{
if(__builtin_popcount(S)==m){
for(int i=0;i<n;i++)
{
if( S & (1<<i))
{
cout<<a[i]<<' ';
}
}
cout<<endl;
}
}
return 0;
}
4、3454:练82.1 涂国旗
【信息学奥赛一本通-编程启蒙】3451【例82.1】不吉利日期
P3392 涂国旗——暴力枚举
C++——涂国旗
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n, m, sum, ans=1e9, a1[55] = {0}, a2[55] = {0}, a3[55] = {0};
char tmp;
cin >> n >> m;
for (int i=1; i<=n; i++) {
for (int j=1; j<=m; j++) {
cin >> tmp;
if (tmp=='W') a1[i]++;
if (tmp=='B') a2[i]++;
if (tmp=='R') a3[i]++;
}
}
for (int w=1; w<=n-2; w++) {
for (int b=1; b<=n-w-1; b++) {
sum = 0;
for (int i=1; i<=w; i++) sum += m-a1[i];
for (int i=w+1; i<=w+b; i++) sum += m-a2[i];
for (int i=w+b+1; i<=n; i++) sum += m-a3[i];
if (sum < ans) ans = sum;
}
}
cout << ans;
return 0;
}
/*
3454:练82.1 涂国旗
http://bas.ssoier.cn:8086/problem_show.php?pid=3454
洛谷刷题C++语言 | P3392 涂国旗
https://blog.csdn.net/guolianggsta/article/details/133760398
https://blog.csdn.net/weixin_43098069/article/details/107484242
https://blog.csdn.net/m0_61775106/article/details/132808404
*/
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n, m, sum, ans=1e9, a1[55] = {0}, a2[55] = {0}, a3[55] = {0};
char tmp;
cin >> n >> m;
for (int i=1; i<=n; i++) {
for (int j=1; j<=m; j++) {
cin >> tmp;
if (tmp=='W') a1[i]++;
if (tmp=='B') a2[i]++;
if (tmp=='R') a3[i]++;
}
}
for (int w=1; w<=n-2; w++) {
for (int b=1; b<=n-w-1; b++) {
sum = 0;
for (int i=1; i<=w; i++) sum += m-a1[i];
for (int i=w+1; i<=w+b; i++) sum += m-a2[i];
for (int i=w+b+1; i<=n; i++) sum += m-a3[i];
if (sum < ans) ans = sum;
}
}
cout << ans;
return 0;
}
5、3455:练82.2 三连击
练82.2三连击
P1618 三连击(升级版)
【信息学奥赛一本通-编程启蒙】3455练82.2 三连击
#include<bits/stdc++.h>
using namespace std;
int b[10];
void go(int x)
{
b[x % 10] = 1;
b[x / 10 % 10] = 1;
b[x / 100] = 1;
}
bool check(int x, int y, int z)
{
memset(b, 0, sizeof(b));
if (y > 999 || z > 999) return 0;
go(x), go(y), go(z);
for (int i = 1; i <= 9; i++)
if (!b[i]) return 0;
return 1;
}
int main()
{
long long A, B, C, x, y, z, cnt = 0;
cin >> A >> B >> C;
for (x = 123; x <= 987; x++)
{
if (x * B % A || x * C % A) continue;
y = x * B / A, z = x * C / A;
if (check(x, y, z))
{
printf("%lld %lld %lld\n",x,y,z);
cnt++;
}
}
if (!cnt) puts("No!!!");
return 0;
}
6、3456:练82.3 选数
练82.3选数
1919:【02NOIP普及组】选数
【信息学奥赛一本通-编程启蒙】3456练82.3 选数
#include<vector>
#include<iostream>
using namespace std;
//判断是否为素数
bool isPrime(int n)
{
bool ret = true;
for (int i = 2; i * i <= n; i++)
{
if (n % i == 0)
{
ret = false;
break;
}
}
return ret;
}
//传入参数:数组arr、还需继续选取个数k、所选定的数之和sum(缺省值为0)、开始搜索下一个数的起始位置pos(缺省值为0)
int dfs(vector<int> arr, int k, int sum = 0, int pos = 0)
{
//如果无需继续选取数,则判断总和是否为素数,直接返回isPrime的结果
if (k == 0)
{
return isPrime(sum);
}
//若k>0,则继续选取下一个数
int ret = 0;
for (int i = pos; i < arr.size(); i++)
{
//调用递归选取下一个数时需要改变的参数:还需继续选取的个数k减去1,sum加上选取的这个数的值,下一次搜索的起始位置为本次搜索的位置+1
ret += dfs(arr, k - 1, sum + arr[i], i + 1);
}
return ret;
}
int main()
{
//参数读取及arr的声明和初始化
int n, k;
cin >> n >> k;
vector<int> arr;
while (n--)
{
int t;
cin >> t;
arr.push_back(t);
}
//调用dfs并打印
cout << dfs(arr, k);
return 0;
}
7、3457:【例83.1】 奥利凡德
【信息学奥赛一本通-编程启蒙】3457【例83.1】 奥利凡德
计蒜客--T1811--奥利凡德
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
const int maxn = 105;
int a[maxn],b[maxn];
int main(){
int n;
while(scanf("%d",&n)!=EOF){
for(int i = 0; i < n; i ++) scanf("%d",&a[i]);
for(int i = 0; i < n; i ++) scanf("%d",&b[i]);
sort(a,a + n);
sort(b,b + n);
int cnt = 0;
for(int i = 0; i < n; i ++){
if(a[i] > b[i]) cnt ++;
}
if(cnt) cout<<"NE"<<endl;
else cout<<"DA"<<endl;
}
return 0;
}
8、3458:【例83.2】二分查找
【信息学奥赛一本通-编程启蒙】3458【例83.2】二分查找
/*
3458:【例83.2】二分查找02
http://bas.ssoier.cn:8086/problem_show.php?pid=3458
*/
#include <bits/stdc++.h>
using namespace std;
int n,a[30005],t,x,lft,rht,mid;
int main( )
{
scanf("%d",&n);
for(int i=1;i<=n;i++)
{
scanf("%d",&a[i]);
}
scanf("%d",&t);
for(int i=1;i<=t;i++)
{
scanf("%d",&x);
lft=0;
rht=n;
while( rht-lft>1){
mid=(lft+rht)/2;
if( a[mid]>=x)
{
rht=mid;
}
else
{
lft=mid;
}
}
if( a[rht]==x)
{
cout<<rht<<' ';
}
else
{
cout<<-1<<' ';
}
}
return 0;
}
9、3459:【例83.3】假币问题
【信息学奥赛一本通-编程启蒙】3459【例83.3】假币问题
牛客 假硬币问题
POJ 2692 称硬币 解题报告
数学模型 商人过河问题 C++实现_商人过河c++-CSDN博客
(c++)枚举--假币问题(详细讲解)
'C 语言' | 假币问题的递归算法
1、查找假币 编写一个实验程序查找假币,有n(n>3)个硬币,其中有一个假币,且假币较轻,采用天平秤重方式找到这个假币,并给出操作步骤。
1、查找假币 编写一个实验程序查找假币,有n(n>3)个硬币,其中有一个假币,且假币较轻,采用天平秤重方式找到这个假币,并给出操作步骤。_找jia币递归出口-CSDN博客
#include <bits/stdc++.h>
using namespace std;
int main( )
{
for(int n;cin>>n,n;)
{
cout<<ceil(log(n)/log(3))<<endl;
}
return 0;
}
10、3460:【例83.4】最大公约数和最小公倍数
[例 83.4] 最大公约数和最小公倍数
1915:【01NOIP普及组】最大公约数与最小公倍数
《小学生C++趣味编程》第42课 最小公倍数
有哪些信息学奥赛相关的比赛和考试
中小学信息学相关比赛汇总(C++类)
信息学奥赛学习、训练、测试的顺序,思路及方法
信息学奥赛学习规划 国内顶尖信息学奥赛名校训练模式 信奥中的数学
信息学奥赛学习规划 国内顶尖信息学奥赛名校训练模式 信奥中的数学_csp-s_dllglvzhenfeng的博客-CSDN博客
信息学奥赛训练体系(2023.02.21)
CSP-J2 CSP-S2 复赛 第2轮 比赛技巧-做题策略与时间分配、容易犯错误汇总 NOI Linux2.0文件操作等
CSP-J2 CSP-S2 复赛 第2轮 比赛技巧-做题策略与时间分配、容易犯错误汇总 NOI Linux2.0文件操作等_dllglvzhenfeng的博客-CSDN博客
NOI Linux 2.0的简单用法、CSP-J2、CSP-S2复赛注意事项等
NOI Linux 2.0的简单用法、CSP-J2、CSP-S2复赛注意事项等_dllglvzhenfeng的博客-CSDN博客
创新、创新思维书籍(2023.10。10)
调试与对拍
信奥中的“骗”分神技 ---“打表”
【NOI2022】PV「什么是信息学精神?」
三年级前如何学习规划
https://www.douyin.com/video/7309415438805404938