浙江工商大学OJ
考研复试
懒狗的救赎
HUMBLE.
展开
-
C语言考试练习题_时间间隔
#include <iostream>#include <cstring>#include <algorithm>#include <cmath>using namespace std;int main(){ int h1,m1,s1,h2,m2,s2; scanf("%d:%d:%d",&h1,&m1,&s1); scanf("%d:%d:%d",&h2,&m2,&s2);原创 2021-03-25 20:06:03 · 529 阅读 · 0 评论 -
括号匹配
代码:利用栈#include <iostream>#include <cstring>#include <stack>#include <algorithm>using namespace std;int main(){ int t; string a; cin>>t; cin.get(); while(t--){ stack<char> s; ci原创 2021-03-25 11:56:27 · 124 阅读 · 0 评论 -
加法与减法
代码:这题吐了,我还以为只有两个加数,但是想要AC,必须是累加器。#include <iostream>#include <cstring>#include <map>using namespace std;int main(){ int n; cin>>n; cin.get(); string s,t; while(n--){ cin>>s; int b=0,s原创 2021-03-25 11:27:52 · 111 阅读 · 0 评论 -
万众期待GCD
#include <iostream>#include <cstring>using namespace std;int get(int a,int b){ int r; while(r=a%b){ a=b; b=r; } return b;}int main(){ int gcd,lcm; while(cin>>gcd>>lcm){ int a=gcd原创 2021-03-25 10:40:13 · 90 阅读 · 0 评论 -
K公好色【动态规划】
#include <cstring>#include <cstdio>#include <iostream>using namespace std;long long dp[35][35];long long fun(int n,int k){ if(dp[n][k]>=0){ return dp[n][k]; } long long ans; if(n==0){ if(k%2==0)原创 2021-03-25 10:16:23 · 163 阅读 · 0 评论 -
恶毒的P
思路:0<x<=1000000000的范围太多,不适合遍历,反向思考S(x)的范围在1~81;代码:#include <iostream>#include <cstring>using namespace std;int getsum(int n){ int s=0; while(n){ s+=n%10; n/=10; } return s;}int main(){ int a,原创 2021-03-25 09:53:40 · 89 阅读 · 0 评论 -
Extra又做算数
代码:不用pow提高效率#include <cstring>#include <cstdio>#include <iostream>#include <map>using namespace std; int main(){ int a; int n[32]; while(cin>>a&&a!=0){ int k=0,t=0; while(a){原创 2021-03-24 21:55:31 · 84 阅读 · 0 评论 -
Extra玩弹珠
代码:原本写了一个O(n^3),发现第二个数据都过不去,直接降到O(n)#include <cstring>#include <cstdio>#include <iostream>#include <map>using namespace std; int main(){ long long n; int t; scanf("%d",&t); while(t--){ cin>>原创 2021-03-24 21:54:25 · 93 阅读 · 0 评论 -
Extra爱嘚瑟
思路:所有数值尾数不断幂次相乘,都会每四轮一循环。通过这个规律可以很简单的求解高次幂。2¹=2 2²=4 2³=8 2⁴=6 2⁵=23¹=3 3²=9 3³=7 3⁴=1 3⁵=34¹=4 4²=6 4³=4 4⁴=6 4⁵=45¹=5 5²=5 5³=5 5⁴=5 5⁵=56¹=6 6²=6 6³=6 6⁴=6 6⁵=67原创 2021-03-24 20:39:17 · 86 阅读 · 0 评论 -
Extra 做算术
#include <cstring>#include <cstdio>#include <iostream>#include <map>using namespace std;int main(){ int t; cin>>t; string a,b; int k=1; while(t--){ cin>>a>>b; int l1=a.size原创 2021-03-24 19:10:50 · 115 阅读 · 0 评论 -
Extra炮女胖友【两种方法】
空间换时间:#include <cstring>#include <cstdio>#include <iostream>#include <map>using namespace std;int main(){ int t; cin>>t; int a[1001]; while(t--){ map<int,int> MAP; int n,x;原创 2021-03-24 18:40:24 · 127 阅读 · 0 评论 -
字符串替换【find()和replace()函数】
代码:#include <cstring>#include <cstdio>#include <iostream>using namespace std;int main(){ string a; string b="you",c="we"; while(getline(cin,a)){ while(a.find(b)!=string::npos){ a.replace(a.find(b),3,原创 2021-03-24 12:16:41 · 723 阅读 · 0 评论 -
分数加减法
#include <string.h>#include <stdio.h>int get(int a,int b){ int r; if(a<0){ a=-a; } while(r=a%b){ a=b; b=r; } return b;}int main(){ int a,b,c,d; char o; while(scanf("%d/%d%c%d/%原创 2021-03-24 11:59:20 · 100 阅读 · 0 评论 -
马戏团【动态规划】
#include <iostream>#include <cstring>using namespace std;int dp[21][21];int fun(int n,int k){ //k表示余额份数 if(dp[n][k]>=0) return dp[n][k]; int ans; if(k<0||k>n) //当余额小于0,或者余额超过n份 ans = 0; else if(n==原创 2021-03-23 19:23:22 · 173 阅读 · 0 评论 -
我删我删,删删删
#include <iostream>#include <cstring>using namespace std;int main(){ string a,t; int n; while(cin>>a>>n){ string mi=a; for(int i=0;i<n;i++){ int l=mi.size(); string temp=mi原创 2021-03-23 18:51:22 · 517 阅读 · 0 评论 -
KY66 点菜问题【0-1背包问题】
记忆性递归法:此题与之前的神奇的口袋极其相似。#include <iostream>#include <cstring>#include <algorithm>using namespace std;int cost[105];int score[105];int dp[105][1005]; //dp记忆方程int fun(int n,int money){ //n为当前的下标,money为剩余的钱 if(dp[n][money]>原创 2021-03-16 18:05:30 · 212 阅读 · 0 评论 -
阶乘分解【20年复试上机真题】
#include <iostream>#include <algorithm>#include <cmath>#include <cstring>#include <map>#include <cstdio>using namespace std;int main(){ int n,k=0; int prime[30]={0}; for(int i=2;i<=100;i++){原创 2021-03-08 14:54:30 · 139 阅读 · 0 评论 -
大仙来了【20年复试上机真题】
实例:1965 1 12013 12 182010 2 11999 7 242008 1 13代码:**#include <iostream>#include <algorithm>#include <cmath>using namespace std;int judge(int n){ if((n%4==0&&n%100!=0)||n%400==0) return 1; return 0;}in原创 2021-03-08 13:26:10 · 327 阅读 · 3 评论 -
守形数【20年复试上机真题】
#include <iostream>#include <algorithm>#include <cmath>using namespace std;int judge(long long n){ long long pow=n*n; int p[100],a[10],i=0,j=0; while(pow){ p[i++]=pow%10; pow/=10; }// for(int k=0;k原创 2021-03-08 12:43:42 · 97 阅读 · 0 评论 -
复利计息法【20年复试上机真题】
#include <iostream>#include <algorithm>#include <cmath>using namespace std;int judge(double a,int b,double c,double x){ double n; for(int i=1;i<=b;i++){ n=a*(1+x)-c; a=n; } if(fabs(n)<0.1)原创 2021-03-08 12:24:33 · 329 阅读 · 0 评论 -
区间最值
思路:[ 1 2 3 4 5 ] 3 1 2 4 0 //排序后:[ 5 2 3 1 4 ] 0 1 2 3 4代码:#include <iostream>#include <cstring>#include <algorithm>#include <cmath>#include <map>using namespace std;typedef struct{ int d; int原创 2021-03-03 18:17:58 · 79 阅读 · 1 评论 -
A+B=X【浙江工商大学oj 详细解析版】
超时代码:最容易想到的,时间复杂度o(n*n),我一以为先排个序,在嵌套循环会快点,能AC掉,提交后发现还是我想多了…#include <iostream>#include <algorithm>using namespace std;int main(){ int t,n,x,a[100000],tag; cin>>t; while(t--){ tag=1; cin>>n>>x;原创 2021-03-03 16:50:17 · 774 阅读 · 1 评论 -
大小数相加【详细注释版】
#include <iostream>#include <cstring>#include <algorithm>#include <cmath>#include <map>using namespace std;int main(){ char a[405],b[405],c[3]=".0",*p1=NULL,*p2=NULL; while(scanf("%s %s",a,b)!=EOF){ int原创 2021-03-03 16:10:53 · 446 阅读 · 1 评论 -
Tom‘s Stutter
代码:#include <iostream>#include <cstring>#include <algorithm>#include <cmath>using namespace std;int main(){ char say[1001],norm[15]="occupation",cop[1001],*p,t[1001]; char add[30]="OH-OH-OH-QQ-PEI-PEI-SHION"; int原创 2021-03-02 16:33:05 · 93 阅读 · 0 评论 -
英文查错系统【浙江工商大学oj 测试点分析】
测试项:第二组极其重要acm4amacmmabmacmaaaaa3aaaaaaaaaaaabaaaaabbbccc4aabbbcccaaabcbcccaaabbbcccaacaabbbccc代码:#include <iostream>#include <cstring>using namespace std;int main(){ string norm,a; int n,k; while(getline(c原创 2021-03-01 16:21:02 · 337 阅读 · 0 评论 -
PQ
#include <iostream>#include <cstdio>#include <string>#include <cstring>#include <cmath>using namespace std;long long getmaxyue(long long a,long long b){ long long r; while(r=a%b){ a=b; b=r;原创 2021-02-28 19:20:27 · 87 阅读 · 0 评论 -
病毒扫描器【测试点分析】
#include <iostream>#include <cstring>#include <cmath>#include <algorithm>using namespace std;int main(){ int n; while(scanf("%d",&n)&&n!=0){ string in[1000],res[1000],temp; int k=0;原创 2021-02-24 16:17:18 · 256 阅读 · 0 评论 -
lisp表达式求值【详细解析版】
Description:lisp是一种非常古老的计算机语言,是由约翰·麦卡锡在1960年左右创造的一种基于λ演算的函数式编程语言,其语法如下:(+ 2 3 4 5)表示2+3+4+5,其值为14(* 2 3 5)表示235,其值为30减法可以表示为:(- 2 3 4)表示:2-3-4=-5即括弧中第一个符号为运算符,后面是操作数,改运算也可以嵌套,比如(* (+ 2 3) 6)表示先计算2+3=5,然后再5*6=30麦卡锡当初提出了一套理论,其核心是一个eval函数,1958年年底,原创 2021-02-22 14:47:23 · 2581 阅读 · 0 评论 -
箱子问题【超级详细解析】
Description:一个工厂制造的产品形状都是长方体,它们的高度都是h,长和宽都相等,一共有6个型号,它们的长宽分别为1×1,2×2,3×3,4×4,5×5,6×6。这些产品通常使用一个6×6×h的长方体包裹包装,然后邮寄给客户。因为邮费很贵,所以工厂要想方设法地减少每个订单运送时的包裹数量。他们很需要有一个好的程序以解决这个问题从而节省费用。现在这个程序由你来设计。Input:每个订单信息用包括6个整数的一行数据表示,中间用空格隔开,分别为1×1至6×6这6种产品的数量。Output:原创 2021-02-21 16:23:12 · 1477 阅读 · 0 评论 -
数字金字塔【两种方法】
方法一:图的遍历#include <iostream>#include <cstring>#include <cmath>#include <algorithm>using namespace std;int path(int a[1000][2000],int x,int y,int n){ int len=a[x][y]; if(x<n){ int len1=len+path(a,x+1,y-1,n);原创 2021-02-20 12:36:21 · 619 阅读 · 0 评论 -
数羊群
#include <iostream>#include <cstring>#include <cmath>#include <algorithm>using namespace std;int cmp(int a,int b){ return a>b;}void find(char a[200][200],int x,int y){ a[x][y]=0; if(a[x+1][y]=='1') find原创 2021-02-20 10:44:53 · 265 阅读 · 0 评论 -
狐狸和绳子的故事
#include <iostream>#include <cstring>#include <cmath>#include <algorithm>using namespace std;int cmp(int a,int b){ return a>b;}int main(){ int t,n; cin>>t; while(t--) { cin >>n;原创 2021-02-19 21:24:13 · 217 阅读 · 0 评论 -
一个奇怪的国家
#include <iostream>#include <cstring>#include <cmath>using namespace std;int main(){ int n,x,k=1; int a[100]={0,2,3}; cin>>n; while(n--) { cin >> x; for(int i=3;i<=x;i++) a[i原创 2021-02-19 20:54:26 · 89 阅读 · 0 评论 -
小明喜欢打DOTA
#include <iostream>#include <string>#include <cmath>using namespace std;typedef struct { double x,y,hp,len;}enemy;int main(){ double a,b,l,r; while(scanf("%lf %lf",&a,&b)!=EOF){ int kill=0; enem原创 2021-02-19 17:23:37 · 128 阅读 · 0 评论 -
【SM】《驯龙高手2》简介【余数定理】
#include <iostream>using namespace std;int main(){ long long k; while(scanf("%lld",&k)!=EOF){ long long int a; a=3*5*7*(k-1)+23; cout<<a<<endl; } return 0;}原创 2021-02-19 15:34:27 · 145 阅读 · 0 评论 -
【SM】相似度
#include <iostream>#include <string>using namespace std;int main(){ string s1,s2; while((getline(cin,s1)&&getline(cin,s2))){ int res[26]={0}; for(int i=0;i<s1.length();i++){ for(int j=0;j<s2原创 2021-02-19 14:40:29 · 234 阅读 · 0 评论 -
Ph.D的科学研究【浙江工商大学oj】
#include <stdio.h>#include <math.h>#include <string.h>int main(){ int n,letter; char number[10][10]={"zero","one","two","three","four","five","six","seven","eight","nine"}; scanf("%d",&n); while(n--) { char原创 2021-02-12 20:22:52 · 268 阅读 · 0 评论 -
80 - 报数问题【浙江工商大学oj】
思路:报数的人是第几个,不是数组序号// 0 1 2// 1 2 0// 0 2// *//// 0 1 2 3 4 5 6// 1 2 0 1 2 0 1// 2 0 1 2 0// 1 2 0// 0 1// *方法一:(超时)#include <stdio.h>int main(){ int n,k,sum,i; while(scanf("原创 2021-02-11 10:44:36 · 226 阅读 · 0 评论 -
最大子串和【浙江工商大学oj】【详细注释版】
#include <stdio.h>int main(){ int n,sum,max,k,tag; while(scanf("%d",&n)!=EOF&&n!=0){ int a[n],res[n]; for(int i=0;i<n;i++){ scanf("%d",&a[i]); } k=0; for(int i=0;i<n;原创 2021-02-09 20:36:50 · 512 阅读 · 0 评论 -
[Jeremy Wu]冒险之路,平凡之路【详细注释版】
代码:#include <stdio.h>int main(){ int n,t,a,b,value,w,e,c,d,sum,turn=1,flag; while(scanf("%d %d",&n,&t)!=EOF){ if(n==0&&t==0) break; int map[2000][2000]={0}; //题目说n<2000,但如果map[200][200]也能AC过原创 2021-02-09 15:19:57 · 200 阅读 · 0 评论