请先学习下知识点,道友!
题目知识点大部分来源于此:
题目思路:
题目代码:
//对于N要进行适应性的更改,对于字段错误
#include
using namespace std;
#define inf 0x3f3f3f3f
#define N 100100
long long n,m,k,g,d,t;
int x,y,z;
char ch;
string str;
vector<int>v[N];
int day[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
int sumday(int y,int m,int d){
int res=0;
for(int i=0;i<m;i++){
res=res+day[i];
}
res=res+d;
if((y%4==0&&y%100!=0)||(y%400==0)){
if(m>2)res++;
}
return res;
}
int main() {
int y,m,d;
while(cin>>y>>m>>d){
cout<<sumday(y,m,d)<<endl;
}
return 0;
}
题目思路:
题目代码:
//对于N要进行适应性的更改,对于字段错误
#include
using namespace std;
#define inf 0x3f3f3f3f
#define N 100100
int n,m,k,g,d;
int x,y,z;
char ch;
string str;
vector<int>v[N];
int check(int x){
int book[15]={0};
int num1=x/1000;
int num2=(x-num1*1000)/100;
int num3=(x-num1*1000-num2*100)/10;
int num4=x%10;
book[num1]=book[num2]=book[num3]=book[num4]=1;
int count=0;
for(int i=0;i<=9;i++){
if(book[i]>0)count++;
}
return count;
}
int main() {
cin>>x>>y;
for(int i=0; ; i++){
if(check(x+i)==y){
printf("%d %04d",i,x+i);
break;
}
}
return 0;
}
题目思路:
对每一天进行模拟遍历
题目代码:
#include
using namespace std;
typedef long long ll;
int d[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int main() {
int ans = 0;
int week = 6;
for (int i = 1; i <= 12; i++) {
for (int j = 1; j <= d[i]; j++) {
if (week == 6 || week == 0 || j == 1 || j == 11 || j == 21 || j == 31) {
ans++;
}
week++;
week = week % 7;
}
}
cout << ans << endl;
return 0;
}
题目思路:
题目代码:
#include
#include
#include
#include
using namespace std;
int days[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int days2[13] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int main() {
int count = 0;
for (int i = 1900; i <= 9999; i++) {
for (int j = 1; j <= 12; j++) {
if (i % 4 == 0 && i % 100 != 0 || i % 400 == 0) {
for (int k = 1; k <= days2[j]; k++) {
string s1 = to_string(i);
string s2 = to_string(j) + to_string(k);
int sum1 = 0, sum2 = 0;
for (char l: s1) sum1 += l - '0';
for (char l: s2) sum2 += l - '0';
if (sum1 == sum2) count++;
}
} else {
for (int k = 1; k <= days[j]; k++) {
string s1 = to_string(i);
string s2 = to_string(j) + to_string(k);
int sum1 = 0, sum2 = 0;
for (char l: s1) sum1 += l - '0';
for (char l: s2) sum2 += l - '0';
if (sum1 == sum2) count++;
}
}
}
}
cout << count << endl;
return 0;
}
题目思路:
题目代码:
#include
using namespace std;
#define int long long
int n;
int last = 0, p = 0; // 上次时间戳与功率
int ans = 0;
// 时间字符串转化为秒作为时间戳
int toSecond(string s) {
int h = (s[0] - '0' + 0) * 10 + (s[1] - '0' + 0);
int m = (s[3] - '0' + 0) * 10 + (s[4] - '0' + 0);
int second = (s[6] - '0' + 0) * 10 + (s[7] - '0' + 0);
return second + m * 60 + h * 60 * 60;
}
signed main() {
string s;
int u, i;
cin >> n;
while (n--) {
cin >> s >> u >> i;
int second = toSecond(s);
ans += p * (second - last);
last = second;
p = u * i;
}
cout << ans << endl;
return 0;
}