ICode9

精准搜索请尝试: 精确搜索
  • [DFS]棋盘问题-POJ 13212021-11-23 21:00:34

    当初学的时候就没学好,现在再学一次。 不过这一次要学的更深。毕竟是健康人了 从零开始的算法生活! Description 在一个给定形状的棋盘(形状可能是不规则的)上面摆放棋子,棋子没有区别。要求摆放时任意的两个棋子不能放在棋盘中的同一行或者同一列,请编程求解对于给定形状和大小的棋盘

  • poj 1065(注意sort函数的使用)2021-11-22 17:00:55

    #include<iostream> #include<algorithm> #include<cstring> using namespace std; #define maxn 5005 typedef struct node{ int x,y; }Point; //int cmp(Point p1,Point p2){ // if(p1.x<=p2.x&&p1.y<=p2.y)return true; // else

  • POJ-1860 Currency Exchange2021-11-22 11:32:33

    传送门 题意:给定起始拥有货币种类为s,拥有数量为v。现有n种不同货币,m种货币转换。货币转换为双向,但两种转换汇率r和手续费c不同。询问是否能够换一圈,最后s的数目增长。(问能否钱从天上来 解:由于要求换一圈货币种类仍为s,所以要求有环。由于不能亏,所以要求是正环。spfa找环即可。 注:sp

  • poj 1064(注意二分搜索变形中l,r,mid的取值和结果取mid还是l 抑或r )2021-11-21 15:01:45

    #include<iostream> #include<cmath> using namespace std; int n,k; int data[10005]; bool check(int len){ int sum = 0; for(int i=0;i<n;i++){ sum += data[i]/len; if(sum>=k)return true; } return false; } int m

  • poj 1088(注意dp的时候,每次的len[i][j]的更新要在循环之外)2021-11-21 14:01:35

    #include<iostream> #include<cstring> #include<cmath> using namespace std; #define maxn 105 int r,c; int data[maxn][maxn],len[maxn][maxn]; const int dx[]={-1,0,1,0},dy[]={0,-1,0,1}; int dp(int x,int y){ if(len[x][y]!=0) return

  • Currency Exchange (POJ 1860)2021-11-18 19:03:17

    Currency Exchange 思路:用spfa来找正环,只要存在一个正环(cnt >= n),那么走这个圈无穷次后资产一定正无穷,因为路是双向的,所以一定可以返回原来的货币,正无穷再怎么亏损,一定还是正无穷 AC Code #include <iostream> #include <cstring> #include <cstdio> #include <queue

  • poj 2301(水题)2021-11-18 18:31:07

    #include<iostream> using namespace std; int main(){ int a,b,n,c,d; scanf("%d",&n); while(n--){ scanf("%d%d",&a,&b); if((a+b)%2==1||a<b){ printf("impossible\n");

  • poj 1936(水题)2021-11-17 11:02:28

    #include<iostream> #include<cstring> using namespace std; int main(){ char a[100005],b[100005]; int i,j,len_a,len_b; while(scanf("%s%s",a,b)==2){ len_a = strlen(a); len_b = strlen(b); j = 0;

  • POJ - Making the Grade(DP)2021-11-15 19:06:09

    POJ - 3666 Making the Grade 对单调上升和单调下降分别求一遍,取最小值即可。 下面只讨论对单调上升的求法。 引理: 一定存在一组最优解,使得每个 B i Bi

  • poj 1010(dfs,根据题意做条件判断,注意数组大小要开大一些,100以上)2021-11-14 20:04:17

    #include<iostream> #include<algorithm> #include<cstring> using namespace std; int data[100],cnt,customer,total,now[5],end_item[5]; int now_type,end_type,now_num,end_num,now_max,end_max; bool none,tie; int get_type(int a[],int n){ so

  • poj 1607(水题)2021-11-14 18:03:48

    #include<iostream> using namespace std; int main(){ int cnt,i,data[105]; double ans[105]; cnt = 0; while(scanf("%d",&data[cnt])==1){ ans[cnt] = 0; for(i=1;i<=data[cnt];i++){ ans[cnt] += 0.

  • poj 1663(水题)2021-11-14 18:02:01

    #include<iostream> using namespace std; int main(){ int n,a,b; scanf("%d",&n); while(n--){ scanf("%d%d",&a,&b); if(a==b){ if(a%2==0){ printf("%d\n",a*

  • poj 1326(水题)2021-11-14 17:32:21

    #include<iostream> #include<cmath> #include<cstring> using namespace std; int main(){ int sum,mile; char a[2][20],icon[2]; while(true){ sum = 0; while(true){ scanf("%s",a[0]);

  • poj 3618(水题)2021-11-13 12:31:43

    #include<iostream> #include<algorithm> #include<cmath> using namespace std; int cmp(int a,int b){ return abs(a)<abs(b); } int main(){ int i,t,n,data[50005]; scanf("%d%d",&t,&n); for(i=0;i<n;i++){

  • poj 1035(水题,注意增删时的操作)2021-11-11 10:03:30

    #include<iostream> #include<cstring> using namespace std; int main(){ char dict[10005][20],tar[20],tmp[20]; int count,i,j,diff_num; bool flag; count = 0; while(scanf("%s",tmp)==1&&strcmp(tmp,"#")

  • poj 1547(水题)2021-11-10 09:02:51

    #include<iostream> using namespace std; int main(){ int n; int x,y,z,data[10]; char name[10][10]; int maxv,minv,maxi,mini; while(scanf("%d",&n)==1&&n!=-1){ maxv = -1; minv = 9999; for

  • poj 1007(sort函数的重写)2021-11-07 14:35:21

    #include<iostream> #include<cstring> #include<string> #include<algorithm> using namespace std; string data[105]; int data_num[105]; int nixushu(string a){ int num = 0; for(int j=0;j<a.length();j++){ for(int k=j+1

  • POJ - 2251 Dungeon Master【搜索】2021-11-05 16:32:41

    题目链接 题意 BFS 题解 BFS #include<iostream> #include<sstream> #include<string> #include<queue> #include<map> #include<set> #include<vector> #include<stack> #include <utility> #include<list> #include<

  • poj 1001(注意输出数据的格式和输出的格式,如空格,回车等)2021-11-04 20:00:57

    #include<iostream> #include<cmath> #include<cstring> using namespace std; int a[200],na,xiaoshu; void multiply(int b){ int i; for(i=0;i<na;i++){ a[i] *= b; } for(i=0;i<na;i++){ if(a[i]>=10){

  • 【POJ 2152】Fire2021-10-31 13:35:38

    题目大意 给你一颗树,每个点都有一个 \(w\) 值,代表在这个点修建工程需要花费 \(w\),还有一个 \(d\) 值,代表离这个点距离小于 \(d\) 的点可以作为这个点的建立工程的点。每条边都有权重,求出覆盖所有点的最小花费。 思路 首先分析,是否具有最优子结构性质,发现任意一颗子树的最小值,都满

  • POJ 1852 java2021-10-27 22:59:21

    下面展示一些 内联代码片。 // A code block var foo = 'bar'; import java.util.*; class Main2 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t=sc.nextInt(); while(t-->0) { int rope=sc.nextInt();//绳长 int

  • Borg Maze POJ - 30262021-10-27 22:34:09

    附上带中文的题目 这个题的题意就是求S和A组成的最小生成树,这题的一个对大部分人来说的一个坑点是读入,我一开始也是被卡了,发现算出来的答案贼大,然后找bug发现读入都没对,后来又用的gets,然后又发现少读了1行,原因是因为在第一行输入2个数字后会有一个回车,这个回车会占一个gets,所

  • POJ 3122 Pie 二分答案2021-10-24 17:01:25

    Pie [POJ 3122] 题目链接:http://poj.org/problem?id=3122 Description My birthday is coming up and traditionally I’m serving pie. Not just one pie, no, I have a number N of them, of various tastes and of various sizes. F of my friends are coming to my part

  • POJ - 2018 Best Cow Fences(二分)2021-10-22 17:32:47

    POJ - 2018 Best Cow Fences #include<iostream> #include<cstdio> using namespace std; const int N = 100010; const double eps = 1e-5; int n,m; int w[N]; double sum[N]; bool check(double avg) { for(int i=1;i<=n;i++) sum[i]=sum[i

  • poj_31902021-10-21 01:03:36

    首先把所有的牛排个序,优先按照起始时间 其次建立一个堆,重载小于号(只可以重载小于号),优先按照右端点的时间排序,大的放下面(sort的时候会放后面),堆顶是结束时间最快的 #include <iostream> #include <algorithm> #include <queue> using namespace std; const int N = 5e4 +

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有