用了两天的中午时间做了一套今年的普及组复赛试题结果测出来分数只有两百!(第三题洛谷全过,lemon却显示编译错误,奇了怪了)
第一题 买铅笔
考查知识点:数学
解题思路:把每个产品买够n支笔时的钱算出来,选取最小的。
代码:
#include <iostream>
#include <cstdio>
using namespace std;
char ch;
int getnum()
{
ch = getchar();
for (; ch < '0' || ch > '9'; ch = getchar());
int ret = 0;
for (; ch >= '0' && ch <= '9'; ch = getchar()) ret = ret * 10 + ch - 48;
return ret;
}
int i,k,a,b,minnum;
int main()
{
k = getnum();
minnum = 1 << 30;
for (i = 1; i <= 3; i++)
{
a = getnum(); b = getnum();
if (a < k)
if (k % a != 0) b = b * (k / a + 1); else b = b * (k / a);
if (b < minnum) minnum = b;
}
printf("%d",minnum);
return 0;
}
第二题:回文日期
考察知识点:日期模拟,判断回文数
题解:
①:设置三个变量,分别模拟年、月、日。
注意当月有多少天?当年有多少天?
②:判断回文数,把原来的数翻转然后跟原来的数判断是否相同即可
代码:
#include <iostream>
#include <cstdio>
using namespace std;
char ch;
int date[4],arrived_date,num,ans;
int getnum()
{
ch = getchar();
for (; ch < '0' || ch > '9'; ch = getchar());
int ret = 0;
for (; ch >= '0' && ch <= '9'; ch = getchar()) ret = ret * 10 + ch - 48;
return ret;
}
void iread()
{
int temp,i;
temp = getnum();
date[1] = temp / 10000; temp %= 10000;
date[2] = temp / 100; temp %= 100;
date[3] = temp;
arrived_date = getnum();
}
bool check()
{
int i,x = 0,y = 0,temp;
x = date[1] * 10000 + date[2] * 100 + date[3];
temp = x;
for (i = 8; i >= 1; i--)
{
y = y * 10 + temp % 10; temp /= 10;
}
if (x == y) return true; else return false;
}
bool check_arrived()
{
int i,x = 0,y = 0;
x = date[1] * 10000 + date[2] * 100 + date[3];
if (x <= arrived_date) return false; else return true;