ACM
skyfengye
研究机器学习,图像处理,图形处理的小菜鸟
展开
-
杭电1089,1090,1091,1092,1093,1094
这是和第1000题相对应的。这些是简单的入门题、所以我在这里就一下全部放上来来。 1089#include <iostream>using namespace std;/*int main(){ int m = 0; int a, b, re; while (cin >> a >> b) { re = a + b;原创 2017-09-29 08:53:38 · 682 阅读 · 0 评论 -
杭电1108 最小公倍数
这是一道简单的求解最小公倍数的题目。一般使用辗转相除法进行求解。代码也比较简单#include<iostream>using namespace std;int gcd(int a,int b){ if(!b) return a; return gcd(b,a%b);}int main(){ int a,b; while(cin>>a>>b原创 2017-10-09 20:00:57 · 261 阅读 · 0 评论 -
杭电1061 Rightmost Digit
这一题一开始我想的挺简单的。一看题目直接动手写了。然后就写了下面的代码#include <iostream>using namespace std;int main(){ int m; cin >> m; while (m) { int n,re=1; cin >> n; for (int i = 0; i <原创 2017-10-01 12:53:24 · 206 阅读 · 0 评论 -
杭电1012 u Calculate e
这一道题一开始看题目觉得挺简单的,所以就直接写代码了。一开始也注意到了要格式化输出。但是在写出代码以后总是发现WA。最后发现还是格式化输出的问题。 这是一开始出现错误的代码#include <iostream>#include <iomanip>using namespace std;int jie(int n){ int sum = 1; for (int i =原创 2017-10-12 21:18:31 · 292 阅读 · 0 评论 -
杭电1040 As Easy As A+B
这一道题说简单是挺简单的,我在这里使用了Vector的概念来做这一道题的,也算一个偷懒吧。这一题相信排序大家很容易可以做出来。但是最后在输出时也许会出现问题。是一个格式问题。在这里再最后输出一个数时不需有空格。这样输出就对了。#include <iostream>#include <vector>#include <algorithm>using namespace std;int main(原创 2017-09-29 22:23:17 · 338 阅读 · 0 评论 -
杭电 1018 Big Number
这一道题一开始看着挺简单的,就是求阶乘然后再求位数。但是理解题意之后发现这个想法有一个很大的问题就是当输入数字很大时就会出现问题 int long 之类的东西无法存储这些数字。所以在网上搜索了一下发现还有一个斯特林公式可以求解这个问题。 斯特林公式 根据上述公式可以得到位数的求解 lnN!=NlnN-N+0.5*ln(2*N*pi) 要想求有多少位,将他换成以10为底便可! 利用换底公式得原创 2017-11-07 22:03:09 · 200 阅读 · 0 评论 -
杭电 1015 Safecracker
一开始看这道题时发现这么多英文,一大堆字母数字,以为这道题很难。把题目看完以后发现就是一系列数字找满足条件的等式。本来打算用枚举法,但是根据做了这么多道题的经验。心里就直接否定了。想着这要直接循环做,要有5个循环,最后肯定超时。想了很久也没有一个头绪。然后网上找了一下发现还真是直接枚举的方法做,所以就顺着开始的思路往下写了如下代码#include <iostream> #include <cst原创 2017-10-30 20:49:06 · 252 阅读 · 0 评论 -
杭电1013 Digital Roots
这一道题看完介绍以后,就直接开始写了。一开始以为挺简单的一个题目。 就写了下面一段代码#include <iostream>using namespace std;int main(){ int a,b; while (cin>>a&&a!=0) { b = (a - 1) % 9 + 1; cout << b << endl;原创 2017-10-16 10:02:32 · 225 阅读 · 0 评论 -
杭电 1017 A Mathematical Curiosity
这一道题一开始看着迷迷糊糊的,也不知道这题讲的什么玩意。大概意思知道是要满足一个等式。然后就开始写了。一开始总是不理解那个输入的N到底用来干什么?前面的题目都是代表多少个测试例子。这次发现这次这个不对。也想不明白。然后认真看看题目发现这题是按组来算的一组一组的。发现这个格式控制太严格了。是每一组之间输入一个空格,但是最后一组不需要输入空格的。然后我写下了如下代码include using names原创 2017-11-01 17:05:51 · 245 阅读 · 0 评论 -
杭电 1019 Least Common Multiple
这一道题是求解最小二乘法,最小二乘法的求法方法有很多。我选取了了一个最简单的方法。就是两个数字相乘除最大公约数的方法。这一道题挺简单的#include<iostream>using namespace std;int gcd(int a, int b){ if (b == 0) return a; else return gcd(b, a%b);原创 2017-11-13 20:42:17 · 484 阅读 · 1 评论 -
杭电 1020 Encoding
这道题很水,没看懂题目时觉得挺复杂的,又要输出数字又要输出字母。于是尝试分开输出然就成功通过了。#include<iostream>#include <string>using namespace std;int main(){ int m; cin >> m; while (m--) { char a[10000]; int原创 2017-11-26 21:12:56 · 194 阅读 · 0 评论 -
杭电2010 水仙花数
这一题也是简单的题目,容易出错的点事 m=n的这种情况很少考虑到。#include<iostream>#include <vector>using namespace std;int main(){ int m, n; int a, b, c; int flag; vector<int> sz; while (cin >> m >> n) {原创 2017-10-08 16:43:50 · 310 阅读 · 0 评论 -
杭电2005 第几天?
这一题最大的变化就是闰年问题。其他基本没有问题#include <iostream>using namespace std;/*int main(){ int d[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; int y, m, r, sum = 0; char c; while (cin>原创 2017-10-08 16:01:30 · 312 阅读 · 0 评论 -
杭电1010 Tempter of the Bone
这一题还是有点难度,一开始没有看懂。然后网上找了一些相关材料,才逐渐看懂整个题目。这里整个代码参考了网上大神的一些代码#include <stdio.h>#include <iostream>#include <string.h>#include <stdlib.h>/*using namespace std;//迷宫地图//X: 墙壁,小狗不能进入//S: 小狗所处的位置//D:原创 2017-09-28 23:54:50 · 177 阅读 · 0 评论 -
杭电1000 A + B Problem
#include <iostream>using namespace std;/*//这一道题中关键点是 多次读入不能只是单次 所以这里使用了whileint main(){int a, b;int sum = 0;while (cin >> a>> b){cout << a + b << endl;}return 0;}*/原创 2017-09-28 23:42:59 · 367 阅读 · 0 评论 -
杭电1001 Sum Problem
#include <iostream>using namespace std;/*//此题难点是需要两次换行符int main(){ int n; int sum = 0; while (cin>>n) { for (int i=0; i<= n;i++) { sum += i; }原创 2017-09-28 23:44:14 · 365 阅读 · 0 评论 -
杭电1002 A + B Problem II
#include<iostream>#include <string>using namespace std;/*int main(){ int sum[1000]; int temp=0; string aL; string bL; int n1,n2,n,tem; int k,t=1,u,v; cin >> k; for原创 2017-09-28 23:45:23 · 264 阅读 · 0 评论 -
杭电1003 Max Sum
#include <iostream>using namespace std;/*int main(){ int T, N, i, j, a[100001]; cin >> T; for (j = 0; j < T; j++) { cin >> N; for (i = 0; i < N; i++) cin原创 2017-09-28 23:46:43 · 309 阅读 · 0 评论 -
杭电1004 Let the Balloon Rise
#include <iostream>#include <string>using namespace std;/*int main(){ int i = 0, N; //string st;// int d; int b[1000]; int max = 0; int q = 0,k=1; char a[1000][16]; wh原创 2017-09-28 23:47:57 · 241 阅读 · 0 评论 -
杭电1005 Number Sequence
#include <iostream>using namespace std;/*int main(){ int a,b,n; int f[50]; while (cin >> a >> b >> n) { if (a==0&&b==0&&n==0)break; f[1] = 1; f[2] = 1;原创 2017-09-28 23:48:33 · 196 阅读 · 0 评论 -
杭电1006 Tick and Tick
这个方法我是参考网上大神写的代码。这一题比较难。看了很久没看懂。没想到最后使用了角速度这个概念。#include<iostream> #include<algorithm> #include<cstdio> #include<cstring> using namespace std;/*// 秒针速度 s = 6°/s 分针速度 m = 1/10° /s 时针 h = 1/1原创 2017-09-28 23:50:02 · 405 阅读 · 0 评论 -
杭电1007 Quoit Design
这一题一开始没有看懂,最后还是参考了网上大神的代码。#include <iostream>#include <algorithm>#include <cstdio>#include <cstring>#include <cmath>/*using namespace std;#define INF 1e20#define N 100010struct Point{ doub原创 2017-09-28 23:51:08 · 224 阅读 · 0 评论 -
杭电1008 Elevator
#include <iostream>using namespace std;/*int main(){ int a[1000] = { 0 }; int m, t = 0; while (cin >> m) { if (m != 0) { t = 0; for (int i =原创 2017-09-28 23:51:39 · 171 阅读 · 0 评论 -
杭电1009 FatMouse' Trade
这一道题使用了贪心算法进行了编写。一开始没有看懂。然后查找了网上一些资料。#include <iostream>#include<algorithm>#include<iomanip>using namespace std;//定义输入仓库的结构体struct trade{ int javaBean;//代表J int cat_food;//代表F double r原创 2017-09-28 23:52:52 · 232 阅读 · 0 评论 -
杭电 1021 Fibonacci Again
这道题开始一看时斐波那契数列题,然后就直接写了。得到下面代码#include <iostream>using namespace std;int fn(int n){ if (n == 0) return 7; else if (n == 1) return 11; else return fn(n - 1) + fn(n原创 2017-11-26 21:29:31 · 302 阅读 · 0 评论