![](https://img-blog.csdnimg.cn/20201014180756930.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
洛谷
Mrrr_Li
时间一直都在向前,你也应该一直向前。
展开
-
P1598 垂直柱状图
#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>#include <cmath>#include <cstdlib>using namespace std;char c;int t[26],i,j,maxx;int main(){ while(~scanf("%c",&c)) if(c&.转载 2020-08-20 06:44:15 · 143 阅读 · 0 评论 -
P1597 语句解析
#include<stdio.h>int a[3];char s1,s2;int main(){ while (scanf("%c:=%c;",&s1,&s2)==2) a[s1-'a']=s2>='0' && s2<='9' ? s2-'0' : a[s2-'a']; //赋值语句简洁明了 printf("%d %d %d",a[0],a[1],a[2]); return 0;}...原创 2020-08-19 14:20:27 · 356 阅读 · 0 评论 -
P1603 斯诺登的密码
#include<bits/stdc++.h>using namespace std;char dic[30][20]={"zero","one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen", "twenty".转载 2020-08-19 13:51:05 · 297 阅读 · 0 评论 -
P1553 数字反转(升级版)
#include<bits/stdc++.h>using namespace std;int main(){ string s; char p=0;//放符号 int cnt=0; cin>>s; for(int i=0;i<s.size();i++) { if(s[i]>='0'&&s[i]<='9') cnt++;//记录第一个数长度 else //.转载 2020-08-19 13:40:34 · 138 阅读 · 0 评论 -
P1321 单词覆盖还原
#include<stdio.h>#include<ctype.h>#include<string.h>#include<math.h>#include<stdlib.h>int boy, girl, n; //自动初始化 int main(){ char a[100000]; scanf("%s", a); int n = strlen(a); for(int i = 0; i < n-2.原创 2020-08-19 13:16:47 · 278 阅读 · 1 评论 -
P3741 honoka的键盘
#include<stdio.h>#include<ctype.h>#include<string.h>#include<math.h>#include<stdlib.h>int isprime(int n){ int k = sqrt(n), i; if ( n <= 1) return 0; else if ( n == 2) return 1; else{ for ( i = 2; i <= k;.原创 2020-08-19 12:51:00 · 221 阅读 · 0 评论 -
P1765 手机
#include<stdio.h>#include<ctype.h>#include<string.h>#include<math.h>#include<stdlib.h>int isprime(int n){ int k = sqrt(n), i; if ( n <= 1) return 0; else if ( n == 2) return 1; else{ for ( i = 2; i <= k;.原创 2020-08-19 12:12:25 · 369 阅读 · 0 评论 -
P1308 统计单词数
C语言学得不精,稍微复杂一点的字符串处理就不会了,在此留下洛谷带佬的C++代码(C++有很多好用的方法),证明我来过(逃#include<iostream>#include<cstring>#include<cstdio>using namespace std;string sent,word;int lens,lenw,t,pos; int main(){ getline(cin,word); getline(cin,sent); .转载 2020-08-19 11:01:56 · 104 阅读 · 0 评论 -
P5734 【深基6.例6】文字处理软件
#include<iostream>#include<cmath>#include<string>#include<fstream>using namespace std;int n,a;string qwq;string c1;string b1;int b,c,d=-1,e;//并不全有用int main(){ cin>>n; cin>>qwq; for(int i=0;i<n;i++) { .转载 2020-08-19 09:27:07 · 294 阅读 · 0 评论 -
P1957 口算练习题
#include <iostream> //cin & cout 用iostream#include <cstring> //memset & strlen 用cstring#include <cstdio> //sscanf & sprintf 用cstdiousing namespace std;int main(){ char a;//a用于存储运算符 int n,c,d;//n存储个数不解释,cd存储两个数字 char s[.转载 2020-08-19 08:38:02 · 262 阅读 · 0 评论 -
P1914 小书童——密码
#include<stdio.h>#include<ctype.h>#include<string.h>#include<math.h>#include<stdlib.h>int main() { int n; scanf("%d", &n); char arr[110]; scanf("%s", arr); int len = strlen(a.原创 2020-08-19 06:53:51 · 169 阅读 · 0 评论 -
P1205 [USACO1.2]方块转换 Transformations
#include<cstdio>#include<cstring>#include<algorithm>using namespace std;const int maxn=12;int n;struct Matrix{ int a[maxn][maxn]; void in(){for(int i=0;i<n;i++)for(int j=0;j<n;j++)scanf(" %c",a[i]+j);} Matrix rot.转载 2020-08-18 20:55:33 · 216 阅读 · 0 评论 -
P1320 压缩技术(续集版)
#include<stdio.h>#include<ctype.h>#include<string.h>#include<math.h>#include<stdlib.h>int main(){ int i, n, num, sum; char text[40000], str[200]; //text:最终字符串,str:缓冲字符串 scanf("%s", str); n = strlen(str);.原创 2020-08-18 20:37:43 · 863 阅读 · 0 评论 -
P1319 压缩技术
#include<stdio.h>#include<ctype.h>#include<string.h>#include<math.h>#include<stdlib.h>#define f(i,j,n) for(i=j;i<=n;i++) //for循环简写,福利福利~int main(){ int n, i = 0, j, k, sum = 0, arr[40000], cnt = 0; scanf.原创 2020-08-18 20:22:42 · 316 阅读 · 0 评论 -
P5731 【深基5.习6】蛇形方阵
这道题数据比较小,打表就完事了,想看正解请移步#include <bits/stdc++.h>using namespace std;int n;int main () { cin >> n; if(n == 1) cout << " 1\n"; if(n == 2) cout <<" 1 2\n 4 3\n"; if(n == 3) { cout << " 1 2 3\n"; cout <&.原创 2020-08-18 19:29:02 · 183 阅读 · 0 评论 -
P1161 开灯
#include<stdio.h>#include<ctype.h>#include<string.h>#include<math.h>#include<stdlib.h>#define f(i,j,n) for(i=j;i<=n;i++) //for循环简写,福利福利~int main(){ int n, t, i, j, ans = 0; double a; scanf("%d", &.原创 2020-08-18 19:17:37 · 386 阅读 · 1 评论 -
P2911 [USACO08OCT]Bovine Bones G
#include<stdio.h>#include<ctype.h>#include<string.h>#include<math.h>#include<stdlib.h>int main(){ int s1, s2, s3, result[100000], i, j, k, temp, max = -1, max2 = -2; scanf("%d %d %d", &s1, &s2, &s3); for.原创 2020-08-18 18:35:40 · 218 阅读 · 0 评论 -
P2141 珠心算测验
#include<stdio.h>#include<ctype.h>#include<string.h>#include<math.h>#include<stdlib.h>int main(){ int m, i, j, k, cnt = 0, sum; scanf("%d", &m); int arr[m], sign[m]; for ( i = 0; i < m; i++) //要做标记,不然可能出现重.原创 2020-08-18 16:22:35 · 114 阅读 · 0 评论 -
P2615 神奇的幻方
#include<stdio.h>#include<ctype.h>#include<string.h>#include<math.h>#include<stdlib.h>#define MAX 45int main(){ int n, x, y, num, i, j; scanf("%d", &n); if (n == 1){ printf("1"); return 0; }.原创 2020-08-18 15:13:19 · 132 阅读 · 0 评论 -
P5729 【深基5.例7】工艺品制作
#include<stdio.h>#include<ctype.h>#include<string.h>#include<math.h>#include<stdlib.h>#define MAX 21int main(){ int i, j, k, w, x, h, q, x1, y1, z1, x2, y2, z2, cnt = 0; scanf("%d %d %d", &w, &x, &h.原创 2020-08-18 12:01:39 · 885 阅读 · 0 评论 -
P1089 津津的储蓄计划
写代码首先要逻辑清晰,这道题是先看她能否剩下钱,如果能,再把整100的存给麻麻,零钱给自己。循环每一轮都先判断她能否剩下钱#include<stdio.h>#include<ctype.h>#include<string.h>#include<math.h>#include<stdlib.h>int main(){ int i, arr[12], result = 0; int sum2 = 0; for (原创 2020-08-16 19:19:23 · 204 阅读 · 0 评论 -
P4956 [COCI2017-2018#6] Davor
注意这道题是刚好52周,所以直接解方程就行了#include<stdio.h>#include<ctype.h>#include<string.h>#include<math.h>#include<stdlib.h>int main(){ int n, x, k; scanf("%d", &n); for (k = 1;; ++k)//k越小越好,上限没有定 for (x = 100;.原创 2020-08-15 17:42:29 · 216 阅读 · 0 评论 -
P1075 质因数分解 题解
#include<stdio.h>#include<ctype.h>#include<string.h>#include<math.h>#include<stdlib.h>int main() { int n, i, j; scanf("%d", &n); for (i = 2; i <= sqrt(n); i++){ if (n%i ==..原创 2020-08-15 17:04:19 · 168 阅读 · 0 评论 -
P1420 最长连号(含注释)
#include<stdio.h>#include<ctype.h>#include<string.h>#include<math.h>#include<stdlib.h>int main() { int n, ans = 0, max = -1, i; scanf("%d", &n); int arr[n]; .原创 2020-08-15 16:42:43 · 492 阅读 · 0 评论 -
P1720 月落乌啼算钱(斐波那契数列)
写递归函数会超时(⊙﹏⊙b汗,注意ans还要初始化,不然过不去#include<stdio.h>#include<ctype.h>#include<string.h>#include<math.h>#include<stdlib.h>double fei(int n){ int i; double num1 = 1, num2 = 1, ans = 0; if ( n == 1 || n == 2) return 1; e.原创 2020-08-15 16:07:29 · 453 阅读 · 2 评论 -
[USACO1.5]回文质数 Prime Palindromes
写代码5分钟, 改代码两小时因为超时改了快半个小时我也是吐了#include<stdio.h>#include<ctype.h>#include<string.h>#include<math.h>#include<stdlib.h>int isprime( int n){ int i, k = sqrt(n); if (n < 2) return 0; else if ( n == 2) return 1; e原创 2020-08-15 15:15:37 · 101 阅读 · 0 评论 -
P2669 金币
#include<stdio.h>#include<ctype.h>#include<string.h>#include<math.h>#include<stdlib.h>int main(){ int K, N, coin = 0; scanf("%d", &K); //输入总天数K for(N = 1; K - N >= 0; K -= N++) //第.原创 2020-08-15 13:44:51 · 163 阅读 · 0 评论 -
P1009 阶乘之和
Python 3高精度n=eval(input()) #输入一个数字n,记得要用eval(),不然输入的是字符串ans=0 #定义一个数,用来保存答案for i in range(1,n+1): #从1到n来算阶乘 d=1 #阶乘值初始化为1 for j in range(1,i+1): d*=j #简单的阶乘算法 ans+=d #每次都加进去print(ans) #.原创 2020-08-15 11:27:36 · 182 阅读 · 0 评论 -
P1888 三角函数
#include<stdio.h>#include<ctype.h>#include<string.h>#include<math.h>#include<stdlib.h>int cmp( void const *a, void const *b){ return (*(int*)a) - (*(int*)b);}int gcd(int a, int b){ return b == 0?a:gcd(b, a%b);}int .原创 2020-08-15 10:10:05 · 236 阅读 · 0 评论 -
P1424 小鱼的航程(改进版)
#include<stdio.h>#include<ctype.h>#include<string.h>#include<math.h>#include<stdlib.h>int main(){ int n, k, ans = 0, i; scanf("%d %d", &n, &k); for( i = 1; i <= k; i++)//要游k天,所以用循环 { i.原创 2020-08-15 09:56:24 · 98 阅读 · 0 评论 -
P1055 ISBN号码
#include<stdio.h>#include<ctype.h>#include<string.h>#include<math.h>#include<stdlib.h>int main(){ char a[14], mod[12] = "0123456789X"; //先将mod11后的十一个字符存入数组 scanf("%s", a); //洛谷用gets读取不让过 int i, j = 1, t = 0; for.原创 2020-08-15 09:35:39 · 145 阅读 · 0 评论 -
P1909 买铅笔
模拟 高性能AC代码:#include<stdio.h>#include<ctype.h>#include<string.h>#include<math.h>#include<stdlib.h>int main() { int n, i, j, k = 0, arr[3][2], temp[3] = {0}, min; scanf("%d", &n); for ( i = 0; i < 3; i.原创 2020-08-14 21:35:51 · 96 阅读 · 0 评论 -
P2181 对角线
#include<stdio.h>#include<ctype.h>#include<string.h>#include<math.h>#include<stdlib.h>int main() { unsigned long long n, ans; scanf("%lld", &n); ans=n * (n-1) / 2 * (n-2) / 3 * (n-3) / 4; printf("%lld.原创 2020-08-14 16:16:42 · 113 阅读 · 0 评论 -
P5709 【深基2.习6】Apples Prologue
代码写得有点乱(逃#include<stdio.h>#include<ctype.h>#include<string.h>#include<math.h>#include<stdlib.h>int main() { int m, t, s; scanf("%d %d %d", &m, &t, &s); if ( t == 0 ){ printf("0"); retur.原创 2020-08-14 16:01:54 · 280 阅读 · 0 评论 -
P5705 【深基2.例7】数字反转
直接输入字符串,然后逆序#include<stdio.h>#include<ctype.h>#include<string.h>#include<math.h>#include<stdlib.h>int revrse(char *arr, int len){ int i, k = 0; char ptr[len + 1]; for (i = len - 1; i >= 0; i--){ ptr[k] = arr[i];.原创 2020-08-14 14:19:58 · 355 阅读 · 0 评论 -
P3742 umi的函数
1.找一个y使f(x,y)=z,已知x,z,且由题目,z中的每一个字符一定都比x中的小。2.故如果z中有一个字符比x中的大,就一定找不到解,可以直接输出-1,结束程序了。3.如果没有,那么z本身也可以作为一个y的解,由于输出任意一个,所以那还找啥,直接输出z。注:全过程没有y的事儿,不用管y#include<stdio.h>#include<ctype.h>#include<string.h>#include<math.h>#include&.原创 2020-08-13 18:32:24 · 436 阅读 · 1 评论 -
P3717 [AHOI2017初中组]cover
模拟 搜索 枚举 暴力 拆分#include<stdio.h>#include<ctype.h>#include<string.h>#include<math.h>#include<stdlib.h>int main(){ int n, m, r, i, j, k, x, y, cnt = 0; scanf("%d %d %d", &n, &m, &r); int sign[105].原创 2020-08-13 15:57:09 · 473 阅读 · 0 评论 -
P3150 pb的游戏(1)
#include<stdio.h>#include<ctype.h>#include<string.h>#include<math.h>#include<stdlib.h>int main(){ int n, i; scanf("%d\n", &n); int num[n]; for ( i = 0; i < n; i++) scanf("%d", &num[i]);.原创 2020-08-13 15:23:38 · 114 阅读 · 0 评论 -
P2524 Uim的情人节礼物·其之弐 题解
康拖展开的函数:int Contor(char s[],int n){ int i, j; int ans=0; for(i=0;i<n;i++) { int smaller=0; for(j= i+1 ;j<n;j++) { if(s[i] > s[j])smaller++; } ans += smaller*fac[n-i-1]; } return ans+1;}AC代码:#include<stdio.h>const ..转载 2020-08-13 13:55:13 · 284 阅读 · 0 评论 -
P1789 【Mc生存】插火把
自己写了快一个小时,数组越界了,只得了20分#include<stdio.h>#include<ctype.h>#include<string.h>#include<math.h>#include<stdlib.h>int main(){ int n, m, i, j, k, l, cnt = 0; scanf("%d %d %d", &n, &m, &k); //m是火把数,k是萤石数.原创 2020-08-13 10:39:14 · 2048 阅读 · 8 评论