![](https://img-blog.csdnimg.cn/20201014180756916.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
HDU
noon/moon
这个作者很懒,什么都没留下…
展开
-
HDU 2098 分拆素数和
#include <bits/stdc++.h>using namespace std;bool is_prime(int n){ for(int i=2;i*i<=n;i++) if(n%i==0) return false; return true;}int main(){ int n; whil...原创 2019-11-07 23:37:08 · 94 阅读 · 0 评论 -
HDU 2097 Sky数
#include <bits/stdc++.h>using namespace std;int main(){ int n,sys[3]={10,12,16}; while(cin>>n&&n){ int t[3]={n,n,n},sum[3]={0}; for(int i=0;i<3;i++){ ...原创 2019-11-07 23:28:40 · 67 阅读 · 0 评论 -
HDU 2099 整除的尾数
#include <bits/stdc++.h>using namespace std;int main(){ int a,b; while(cin>>a>>b&&(a||b)){ int sum=a*100,f=0; for(int i=0;i<100;i++) ...原创 2019-11-07 23:18:12 · 63 阅读 · 0 评论 -
HDU 2084 数塔
从上向下累加最优子结构#include <bits/stdc++.h>using namespace std;int main(){ int c;cin>>c; while(c--){ int n;cin>>n; int a[n+1][n+1]={0}; for(int i=1;i<=n...原创 2019-11-06 23:55:56 · 80 阅读 · 0 评论 -
HDU 2083 简易版之最短距离
高中数学选修4-5(真怀念啊)#include <bits/stdc++.h>using namespace std;int main(){ int m;cin>>m; while(m--){ int n;cin>>n; int a[n],sum=0; for(int i=0;i<n;i...原创 2019-11-06 23:53:02 · 53 阅读 · 0 评论 -
HDU 2081 手机短号
#include <bits/stdc++.h>using namespace std;int main(){ int n;cin>>n; while(n--){ string s;cin>>s; cout<<"6"+s.substr(s.size()-5)<<endl; } ...原创 2019-11-06 23:50:42 · 124 阅读 · 0 评论 -
HDU 2050 折线分割平面
#include <bits/stdc++.h>using namespace std;int main(){ int t;cin>>t; while(t--){ int n;cin>>n; cout<<2*n*n-n+1<<endl; } return 0;}参考...原创 2019-11-06 23:43:41 · 57 阅读 · 0 评论 -
HDU 2043 密码
#include <bits/stdc++.h>using namespace std;bool isch(char c){ return (c=='~')||(c=='!')||(c=='@')||(c=='#')||(c=='$')||(c=='%')||(c=='^');}int main(){ int n;cin>>n; while(...原创 2019-11-06 23:31:06 · 82 阅读 · 0 评论 -
HDU 2042 不容易系列之二
#include <bits/stdc++.h>using namespace std;int main(){ int n;cin>>n; while(n--){ int num,sheep=3; cin>>num; while(num--) sheep=(sheep-1...原创 2019-11-06 23:29:23 · 80 阅读 · 0 评论 -
HDU 2041 超级楼梯
#include <bits/stdc++.h>using namespace std;int ans[50]={0,1,1};int Floor(int n){ return ans[n]?ans[n]:ans[n]=Floor(n-1)+Floor(n-2);}int main(){ int n;cin>>n; Floor(40); ...原创 2019-11-06 23:28:38 · 58 阅读 · 0 评论 -
HDU 2040 亲和数
#include <bits/stdc++.h>using namespace std;int main(){ int n;cin>>n; while(n--){ int a,b,suma=0,sumb=0; cin>>a>>b; for(int i=1;i<a;i++) ...原创 2019-11-06 23:26:37 · 50 阅读 · 0 评论 -
HDU 2092 整数解
#include <bits/stdc++.h>using namespace std;int is_square(int n){ for(int i=1;i*i<=n;i++) if(i==n/i&&n%i==0) return i; return 0;}int main(){ int a,...原创 2019-11-06 23:20:23 · 93 阅读 · 0 评论 -
HDU 2091 空心三角形
#include <bits/stdc++.h>using namespace std;int main(){ char c;int n,f=0; while(cin>>c&&c!='@'){ cin>>n; if(f++)//控制样板三角形间的空行 cout<&l...原创 2019-11-06 23:00:38 · 90 阅读 · 0 评论 -
HDU 2090 算菜价
#include <bits/stdc++.h>using namespace std;int main(){ string name; double num,unit,sum=0.0; while(cin>>name>>num>>unit) sum+=num*unit; printf("%.1f\...原创 2019-11-06 22:43:11 · 189 阅读 · 0 评论 -
HDU 2096 小明A+B
#include <bits/stdc++.h>using namespace std;int main(){ int n;cin>>n; while(n--){ int a,b;cin>>a>>b; cout<<(a%100+b%100)%100<<endl; }...原创 2019-11-06 22:37:37 · 92 阅读 · 0 评论 -
HDU 2088 Box of Bricks
#include <bits/stdc++.h>using namespace std;int main(){ int n,f=0; while(cin>>n&&n){ int a[n],sum=0; for(int i=0;i<n;i++) cin>>a[i],s...原创 2019-11-04 23:33:43 · 81 阅读 · 0 评论 -
HDU 2087 剪花布条
#include <bits/stdc++.h>using namespace std;int main(){ string a; while(cin>>a&&a!="#"){ string b;cin>>b; int ans=0,pos=a.find(b); while(pos...原创 2019-11-04 23:30:54 · 70 阅读 · 0 评论 -
HDU 2086 A1 = ?
已知条件:Ai = (Ai-1 + Ai+1)/2 - Ci (i = 1, 2, 3, … n) ①①累加得:A1 + An = A0 + An+1 - 2(C1 + C2 …+Cn) ②②累加得:(n+1) A1 = nA0 + An+1 - 2(nC1 + (n-1)C2 + … + Cn)&nb...原创 2019-11-04 00:53:41 · 78 阅读 · 0 评论 -
HDU 2085 核反应堆
#include <bits/stdc++.h>using namespace std;typedef long long ll;int main(){ ll n,high[35]={1},low[35]={0}; for(int i=1;i<=33;i++){ high[i]=3*high[i-1]+2*low[i-1]; ...原创 2019-11-03 22:52:04 · 136 阅读 · 0 评论 -
HDU 2056 Rectangles
#include <bits/stdc++.h>using namespace std;double x[4],y[4];bool inter(){ sort(x,x+2);sort(x+2,x+4); sort(y,y+2);sort(y+2,y+4); return x[0]<x[3]&&x[1]>x[2]&&...原创 2019-11-03 18:50:13 · 74 阅读 · 0 评论 -
HDU 2063 过山车
第一次接触图论,这个问题属于图论中的二分图最大匹配。参考博客:趣写算法系列之–匈牙利算法#include <bits/stdc++.h>using namespace std;int line[510][510],boy[510],used[510];int k,m,n,a,b;bool Find(int x){ for(int j=1;j<=n;j++){...原创 2019-11-01 17:25:57 · 71 阅读 · 0 评论 -
HDU 2057 A + B Again
正常版本:#include <bits/stdc++.h>using namespace std;typedef long long ll;int main(){ ll a,b; while(scanf("%llX%llX",&a,&b)!=EOF){ if(a+b>=0) printf("%llX\...原创 2019-10-30 01:15:33 · 98 阅读 · 0 评论 -
HDU 2055 An easy problem
#include <bits/stdc++.h>using namespace std;int main(){ int n;cin>>n; while(n--){ char x;int y;cin>>x>>y; if(isupper(x)) cout<<x-'A'+1+y<<...原创 2019-10-30 00:13:47 · 70 阅读 · 0 评论 -
HDU 2053 Switch Game
#include <bits/stdc++.h>using namespace std;int main(){ int n; while(cin>>n){ int cnt=0; for(int i=1;i<=n;i++) if(n%i==0) cnt++; cout<&l...原创 2019-10-29 17:51:08 · 96 阅读 · 0 评论 -
HDU 2052 Picture
#include <bits/stdc++.h>using namespace std;inline void print(char h,char mid,int n_mid){ cout<<h;for(int i=0;i<n_mid;i++)cout<<mid;cout<<h<<endl;}int main(){ ...原创 2019-10-29 17:47:33 · 52 阅读 · 0 评论 -
HDU 2051 Bitset
做完递推终于可以做些水题放松一下了…好像不想再用int了…#include <bits/stdc++.h>using namespace std;typedef long long ll;int main(){ ll n; while(cin>>n){ ll ten=n,two[15],p=0; while(ten&...原创 2019-10-27 22:53:10 · 58 阅读 · 0 评论 -
HDU 2049 不容易系列之(4)——考新郎
1.先从n个新郎中选出m个,即Cnm2.再算出m个新郎的错排数,即f(m)组合的递推公式以及错排公式的推导参考Hdu 2049解题报告这里我将组合的求法由递归改为了递推#include <bits/stdc++.h>using namespace std;typedef long long ll;ll c[25][25],f[25]={0,0,1};void Init(...原创 2019-10-27 22:18:51 · 147 阅读 · 0 评论 -
HDU 2047 阿牛的EOF牛肉串
参考博客:HDU2047——上进小青年第n位字符分两种情况:E、F:第n-1位的字符无限制,共有f(n-1)*2种情况O:第n-1位的字符只能为E、F,共有f(n-2)*2种情况#include <bits/stdc++.h>using namespace std;typedef long long ll;int main(){ ll n,dp[40]={0,3,...原创 2019-10-24 22:36:22 · 120 阅读 · 0 评论 -
HDU 2046 骨牌铺方格
这篇博客解题思路很明了:HDU 2046 骨牌铺方格(简单递推)直接以最后一块骨牌分情况:骨牌竖放:共有f(n-1)种情况骨牌横置:共有f(n-2)种情况所以可得:f(n)=f(n-1)+f(n-2)(这不是斐波那契数列吗?)#include <bits/stdc++.h>using namespace std;typedef long long ll;int main...原创 2019-10-24 22:01:51 · 309 阅读 · 0 评论 -
HDU 2045 不容易系列之(3)—— LELE的RPG难题
这篇博客讲得比较好:RPG难题—HDU2045(解题报告)#include <bits/stdc++.h>using namespace std;typedef long long ll;int main(){ ll n,dp[51]={0,3,6,6}; for(int i=4;i<=50;i++) dp[i]=dp[i-1]+dp[i...原创 2019-10-24 21:42:28 · 169 阅读 · 0 评论 -
HDU 2044 一只小蜜蜂...
用long long#include <bits/stdc++.h>using namespace std;typedef long long ll;int main(){ ll dp[50]={0,1,1,2}; for(ll i=4;i<50;i++) dp[i]=dp[i-1]+dp[i-2]; ll n;cin>>...原创 2019-10-24 20:40:23 · 65 阅读 · 0 评论 -
HDU 2028 Lowest Common Multiple Plus
最小公倍数 = 两个数的积 / 最大公约数#include <iostream>using namespace std;typedef long long ll;ll gcd(ll a,ll b){ return b==0?a:gcd(b,a%b);}int main(){ ll n,t; while(cin>>n){ l...原创 2019-10-24 00:55:42 · 53 阅读 · 0 评论 -
HDU 2035 人见人爱A^B
决定积后三位的只有乘数们的后三位#include <bits/stdc++.h>using namespace std;int main(){ int a,b; while(cin>>a>>b&&(a||b)){ int ans=a%=1000; while(--b) ...原创 2019-10-24 00:52:25 · 68 阅读 · 0 评论 -
HDU 2034 人见人爱A-B
#include <bits/stdc++.h>using namespace std;int main(){ int a,b; while(cin>>a>>b&&(a||b)){ int m_a[105]={0},m_b[105]={0},flag=1,t; while(a--) ...原创 2019-10-24 00:44:18 · 74 阅读 · 0 评论 -
HDU 2033 人见人爱A+B
统一转化为最小单位#include <bits/stdc++.h>using namespace std;int n,h1,m1,s1,h2,m2,s2,sum;int main(){ cin>>n; while(n--){ cin>>h1>>m1>>s1>>h2>>m2&g...原创 2019-10-24 00:42:40 · 52 阅读 · 0 评论 -
HDU 2029 Palindromes _easy version
#include <bits/stdc++.h>using namespace std;int n;string s;bool is(string s){ int l=s.length(); for(int i=0;i<l/2;i++) if(s[i]!=s[l-i-1]) return false; return true;}i...原创 2019-10-24 00:39:37 · 62 阅读 · 0 评论 -
HDU 2039 三角形
用double#include <bits/stdc++.h>using namespace std;int main(){ int n; cin>>n; while(n--){ double a,b,c; cin>>a>>b>>c; printf("%s\n",a+b>c&&...原创 2019-10-24 00:30:41 · 70 阅读 · 0 评论 -
HDU 2027 统计元音
#include <iostream>#include <map>using namespace std;int main(){ int n;cin>>n; getchar(); string s; while(n--){ getline(cin,s); map<char,int>...原创 2019-10-18 18:19:18 · 53 阅读 · 0 评论 -
HDU 2026 首字母变大写
#include <iostream>#include <cctype>using namespace std;int main(){ string s; while(getline(cin,s)){ s.insert(0," "); for(int i=1;i<s.size();i++) ...原创 2019-10-18 17:51:49 · 89 阅读 · 0 评论 -
HDU 2025 查找最大元素
#include <iostream>using namespace std;int main(){ string s; while(cin>>s){ char m='a'; for(int i=0;i<s.size();i++) if(s[i]>m) m=s[i]; f...原创 2019-10-18 17:21:51 · 80 阅读 · 0 评论