- 博客(21)
- 收藏
- 关注
原创 NYOJ 308 Substring
题目:NYOJ 308 Substring思路:将元素组a逆置得到数组b,求a和b的最长公共子串#include <stdio.h> #include <string.h> int main() { char a[55],b[55]; int c[55][55],t; scanf("%d",&t); while(t--) { mems
2017-09-23 16:21:13 240
原创 NYOJ 678 最小K个数之和
题目:NYOJ 最小K个数之和该咋说,其实是蛮简单的一道题,愣是不敢做,哎,,,思路:先按从小到大排序,再求和#include <stdio.h> #include <algorithm> using namespace std; int a[100005]; int main() { int n,k; while(scanf("%d %d",&n,&k)!=EOF) {
2017-09-22 15:42:47 382
原创 NYOJ 1058 部分和问题(dfs)
题目:NYOJ 1058 部分和问题好吧,简单的深度搜索#include <stdio.h> #include <string.h> #include <stdlib.h> #include <stack> using namespace std; int num[25],vis[25]; int flag,n,k;void dfs(int m,int sum) { if(sum>k)
2017-09-22 15:15:39 275
原创 NYOJ 588 Money
题目:NYOJ 588 Money思路:i*0.5+j*0.2+k*0.1*=n,等号两边同乘以10即 5i+2j+k=n*10,模拟此式#include <stdio.h> int main() { int t; scanf("%d",&t); while(t--) { int n,i,j,k,ans=0; scanf("%d",
2017-09-22 13:57:59 279
原创 NYOJ 45 棋盘覆盖 (大数问题+C语言)
题目:NYOJ 45 棋盘覆盖 刚学习了用java解决大数的问题,又做了一遍 2018.5.3 其实这道题就是大数问题 思路:利用数组模拟笔算,求出棋盘的面积(大数),用得出的面积除以3,其实不用减1就可以 #include <stdio.h> #include <string.h> #include <stdlib.h> #define...
2017-09-18 22:06:39 891
原创 NYOJ 28 大数阶乘(C语言)
题目:NYOJ 28 大数阶乘 刚学会用java,就用java写了个,真方便啊 2018.5.3 写的第一个大数的问题,刚开始感觉无从下手,主要还是刚刚接触,还需要多加练习,加油吧! 思路:利用数组模拟笔算过程 #include <stdio.h> #include <string.h> #include <stdlib.h> #defin...
2017-09-18 14:05:26 550
原创 NYOJ 663 弟弟的作业
题目:NYOJ 663 弟弟的作业这道题让我又回顾了一下atof函数的用法,atof函数在头文件< stdlib.h >和< algorithm >中包含的都有,作用把字符串转换为浮点型数,用起来挺方便的 这只是我的一点小的思路,肯定有比这个更简单的#include <stdio.h> #include <string.h> #include <stdlib.h> int main() {
2017-09-09 14:21:06 563
原创 木棒 xynuoj 1737 && 心急的C小加 nyoj 236
1737: 木棒 时间限制: 1 Sec 内存限制: 32 MB 提交: 20 解决: 17 您该题的状态:已完成 [提交][状态][讨论版] 题目描述 现有n根木棒,已知它们的长度和重量。要用一部木工机一根一根地加工这些木棒。该机器在加工过程中需要一定的准备时间,是用于清洗机器,调整工具和模板的。木工机需要的准备时间如下: (1)第一根木棒需要1min的准备时间; (2)...
2017-09-04 22:02:21 250
原创 NYOJ 12 喷水装置(二)
题目链接:NYOJ 12 喷水装置(二)#include <stdio.h> #include <math.h> #include <algorithm> using namespace std;struct node{ //定义结构体,存储每个喷水装置可以全部覆盖的起点和终点 double st,en; }a[10001];int cmp(node m, node
2017-09-04 21:36:33 236
原创 NYOJ 101 两点距离
题目:NYOJ 101 两点距离就是一个距离公式,我是用的math头文件里的函数写的#include <stdio.h> #include <math.h> int main() { int n; double x1,y1,x2,y2,l; scanf("%d",&n); while(n--) { scanf("%lf %lf %lf %l
2017-09-03 15:27:17 229
原创 NYOJ 97 兄弟郊游问题
题目:NYOJ 97 兄弟郊游问题真的是很经典的数学问题#include <stdio.h> int main() { int n; scanf("%d",&n); while(n--) { double a,b,c,d,s,e; scanf("%lf %lf %lf %lf",&a,&b,&c,&d); e=(a*
2017-09-03 15:05:54 344
原创 NYOJ 733 万圣节派对
题目:NYOJ 733 万圣节派对#include <stdio.h> #include <math.h> int main() { int t; scanf("%d",&t); while(t--) //t组测试数据 { int m,n,i,j,k; int a[6]; scanf("%d %d",&m,&n);
2017-09-03 14:50:07 328
原创 NYOJ 599 奋斗的小蜗牛
题目:NYOJ 599 奋斗的小蜗牛#include <stdio.h> int main() { int m,n; long int h,c; scanf("%d",&m); while(m--) { c=0; //蜗牛每天到达的高度 n=1; scanf("%ld",&h); if(h<
2017-09-03 14:29:11 378
原创 NYOJ 60 谁获得了最高奖学金
题目:NYOJ 60 谁获得了最高奖学金其实这道题就是题目长了点,if语句比较多,写的时候注意细节,不然很容易出错#include <stdio.h> #include <string.h> int main() { int n,m,i,s1,s,a,b,e,max; char f[20],h[20],c,d; scanf("%d",&n); //测试数据的组数
2017-09-03 13:56:22 271
原创 NYOJ 39 水仙花数
题目:NYOJ 39 水仙花数下面这种方法是每次输入都要计算#include <stdio.h> #include <math.h> int main() { int n,g,s,b; while(~scanf("%d",&n)) { if(n==0) break; g=n%10; //个位
2017-09-03 13:33:34 336
原创 NYOJ 62 笨小熊
题目:NYOJ 62 笨小熊#include <stdio.h> #include <string.h>int prime(int x) //素数的判定 { if(x==0 || x==1) return 0; for(int i=2;i*i<=x;i++) if(x%i==0) return 0; return
2017-09-02 20:01:24 361
原创 NYOJ 399 整除个数
题目:NYOJ 399 整除个数这个题坑了不少人呐,用for循环你就输了,仔细想一想,不就是m中有多少个b嘛,m/b不就行了#include <stdio.h> int main() { int m,b,k; while(~scanf("%d %d",&m,&b)) { k=m/b; printf("%d\n",k); }
2017-09-02 19:37:29 207
原创 NYOJ 845 无地之主1
题目:NYOJ 845 无地之主1#include <stdio.h> int main() { int a[110],b[110]; //a[i]存储 区域标号,b[i]存储 对应区域的任务个数 int m,n,i=1,j; while(~scanf("%d %d",&m,&n)) { if(m==0 && n==0)
2017-09-02 19:26:31 339
原创 NYOJ 57 6174问题
题目:NYOJ 57 6174问题#include <stdio.h>int change(int m) // 对m进行题目中的操作 { int i,j,k,b,c,t; int a[10]; b=0; c=0; k=0; while(m) //把m的每位数存入数组 a { a[k]=m%10;
2017-09-02 15:43:51 281
原创 NYOJ 259 茵茵的第一课
NYOJ 259 茵茵的第一课#include <stdio.h> int main() { int n,k=1; char c[25]; //数组一定要大一些 scanf("%d",&n); while(k<=n) { scanf("%s",c); printf("%s\n",c);
2017-09-02 15:20:07 451
原创 NYOJ 24 素数距离问题
NYOJ 24 素数距离问题 //思路:若n不为素数,同时向前和向后找素数(n=1时,单独输出),找到就结束循环 #include <stdio.h> #define N 1000050 bool prime[N]; void init()//筛选法求素数 { for(int i=2;i<N;i++) prime[i] = true; ...
2017-09-02 15:03:52 302
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人