Sink

沉舟侧畔千帆过

  • 主页
  • 归档
  • 书籍
  • 书签
  • 技能树
  • 工具箱
  • LeetCode
  • 关于我
所有文章 友情链接 +1s

  • 主页
  • 归档
  • 书籍
  • 书签
  • 技能树
  • 工具箱
  • LeetCode
  • 关于我

P1398 奖学金 解题报告

Published on 2009 / 05 / 10

题目简单,直接搜索过。

编译通过…
├ 测试数据 01:答案正确… 0ms
├ 测试数据 02:答案正确… 0ms
├ 测试数据 03:答案正确… 0ms
├ 测试数据 04:答案正确… 0ms
├ 测试数据 05:答案正确… 0ms
├ 测试数据 06:答案正确… 0ms
├ 测试数据 07:答案正确… 0ms
├ 测试数据 08:答案正确… 0ms
├ 测试数据 09:答案正确… 0ms
├ 测试数据 10:答案正确… 0ms
Accepted 有效得分:100 有效耗时:0ms

我的程序

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include<stdio.h>
int num,score[300][4],count[300];
int Compare(int a,int b)
{
if(score[count][1]<=score[count[a]][1])
count=count[a];
return b;
}
void Score()
{
int max,i,j,k;
for(max=0,i=0;i<num;i++)
if(max<score[0])
max=score[0];
for(i=0,j=0;i<num;i++)
if(max==score[0])
{count[j]=i;j++;}
if(j==1)
{k=j;printf("%d %d\n",count[k-1]+1,score[count[k-1]][0]);}
else
{
for(i=1;i<=j;i++)
k=Compare(i-1,i);
printf("%d %d\n",count[k-1]+1,score[count[k-1]][0]);
}
score[count[k-1]][0]=0;
}
int main()
{
scanf("%d",&num);
int i;
for(i=0;i<num;i++)
scanf("%d %d %d",&score[1],&score[2],&score[3]);
for(i=0;i<num;i++)
score[0]=score[1]+score[2]+score[3];
for(i=0;i<5;i++)
{memset(count,0,sizeof(count));Score();}
return 0;
}
  • vijos

展开全文 >>

P1093 文科生的悲哀 解题报告

Published on 2009 / 05 / 05

题目地址:http://www.vijos.cn/Problem_Show.asp?id=1093

递归加记忆化搜索。

编译通过…
├ 测试数据 01:答案正确… 0ms
├ 测试数据 02:答案正确… 0ms
├ 测试数据 03:答案正确… 0ms
├ 测试数据 04:答案正确… 0ms
├ 测试数据 05:答案正确… 0ms
├ 测试数据 06:答案正确… 0ms
├ 测试数据 07:答案正确… 0ms
├ 测试数据 08:答案正确… 0ms
├ 测试数据 09:答案正确… 0ms
├ 测试数据 10:答案正确… 0ms
Accepted 有效得分:100 有效耗时:0ms

我的程序:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include<stdio.h>
int n;
long times,save[4][10000];
int Cal(int subject,int num)
{
if(save[subject-1][num]==0)
{
if(num==0)
save[subject-1][num]=1;
else
{
if(subject==1)
save[subject-1][num]=Cal(2,num-1);
else if(subject==2)
{
save[subject-1][num]=Cal(1,num-1);
save[subject-1][num]%=7654321;
save[subject-1][num]+=Cal(3,num-1);
save[subject-1][num]%=7654321;
}
else if(subject==3)
{
save[subject-1][num]=Cal(2,num-1);
save[subject-1][num]%=7654321;
save[subject-1][num]+=Cal(4,num-1);
save[subject-1][num]%=7654321;
}
else
{
save[subject-1][num]=Cal(3,num-1);
save[subject-1][num]%=7654321;
}
}
}
return save[subject-1][num];
}
int main()
{
scanf("%d",&n);
times=Cal(1,n-1);
printf("%ld",times);
return 0;
}
  • vijos

展开全文 >>

P1096 津津的储蓄计划 解题报告

Published on 2009 / 05 / 05

题目地址:http://www.vijos.cn/Problem_Show.asp?id=1096

这题本来很水,可是粗心。在增加百分之二十的时候犯了一点小错误,提交了3次才AC。对自己无语……

编译通过…
├ 测试数据 01:答案正确… 0ms
├ 测试数据 02:答案正确… 0ms
├ 测试数据 03:答案正确… 0ms
├ 测试数据 04:答案正确… 0ms
├ 测试数据 05:答案正确… 0ms
├ 测试数据 06:答案正确… 0ms
├ 测试数据 07:答案正确… 0ms
├ 测试数据 08:答案正确… 0ms
├ 测试数据 09:答案正确… 0ms
├ 测试数据 10:答案正确… 0ms
Accepted 有效得分:100 有效耗时:0ms

我的程序(C语言):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include<stdio.h>
int main()
{

int i,j,pan,money,save,budget[12];
for(i=0,m,save=0;i<12;i++)
scanf("%d",&budget);
for(i=0,pan=1;i<12;i++)
{
money+=300;
money-=budget;
if(money<0)
{i++,pan=0;break;}
else
{
j=money/100;
money%=100;
save+=j*100;
}
}
if(pan==1)
printf("%d",save*6/5+money);
else
printf("-%d",i);
return 0;
}
  • vijos

展开全文 >>

P1303 导弹拦截 解题报告

Published on 2009 / 05 / 05

题目地址:http://www.vijos.cn/Problem_Show.asp?id=1303 ;

这道题相信大家在刚开始学动态规划时就做过,Vijos上的这道稍微修改了一下,所以不能直接提交原来的程序。题目要求再输出还需多少枚导弹,可以直接重复求最大,我就没有写成函数,直接用 goto 了。

编译通过…
├ 测试数据 01:答案正确… 0ms
├ 测试数据 02:答案正确… 0ms
├ 测试数据 03:答案正确… 0ms
├ 测试数据 04:答案正确… 0ms
├ 测试数据 05:答案正确… 0ms
├ 测试数据 06:答案正确… 0ms
Accepted 有效得分:100 有效耗时:0ms

代码如下(C语言):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include<stdio.h>
int i,j,k,n,max,count,f[10000],a[10000],temp[10000];
int main()
{
char ch;
do
{
scanf("%d",&a[n]);
ch=getchar();
n++;
}while(ch!='\n');
for(i=0;i<n;i++)
f=1;
for(i=n-2;i>=0;i--)
{
for(j=i+1;j<n;j++)
if(a[j]<=a&&f[j]+1>f)
f=f[j]+1;
}
for(i=0;i<n;i++)
if(f>max)
max=f;
printf("%d,",max);
k=max;
for(i=0;i<n;i++)
if(f==max)
{;j=a;break;}
for(;i<n;i++)
if(f==max&&j>=a)
{
j=a;
a=0;
max--;
}
start:
if(k!=n)
{
count++;
for(i=0,j=0;i<n;i++)
if(a!=0)
{temp[j]=a;j++;}
memset(a,0,sizeof(a));
for(i=0;i<j;i++)
a=temp;
memset(f,0,sizeof(f));
memset(temp,0,sizeof(temp));
n=j;
for(i=0;i<n;i++)
f=1;
for(i=n-2;i>=0;i--)
{
for(j=i+1;j<n;j++)
if(a[j]<=a&&f[j]+1>f)
f=f[j]+1;
}
for(i=0;i<n;i++)
if(f>max)
max=f;
k=max;
for(i=0;i<n;i++)
if(f==max)
{;j=a;break;}
for(;i<n;i++)
if(f==max&&j>=a)
{
j=a;
a=0;
max--;
}
goto start;
}
printf("%d",count);
return 0;
}
  • vijos

展开全文 >>

P1025 小飞侠的游园方案 解题报告

Published on 2009 / 04 / 26

类似 0/1背包的问题,还是记忆化加动态规划,很简单就可以过。

编译通过…
├ 测试数据 01:答案正确… 0ms
├ 测试数据 02:答案正确… 0ms
├ 测试数据 03:答案正确… 0ms
├ 测试数据 04:答案正确… 0ms
├ 测试数据 05:答案正确… 0ms
├ 测试数据 06:答案正确… 0ms
├ 测试数据 07:答案正确… 0ms
├ 测试数据 08:答案正确… 0ms
├ 测试数据 09:答案正确… 0ms
├ 测试数据 10:答案正确… 0ms
Accepted 有效得分:100 有效耗时:0ms

附代码(C语言):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include<stdio.h>
#include<stdlib.h>
int N,t,maxfi,fi[101],ti[101],save[101][1002];
int MaxHappy(int site,int time);
int Max(int a,int b);
int main()
{
scanf("%d",&N);
scanf("%d",&t);
int i;
for(i=0;i<N;i++)
scanf("%d %d",&fi,&ti);
maxfi=MaxHappy(0,t);
printf("%d",maxfi);
return 0;
}
int MaxHappy(int site,int time)
{
if(save[site][time]==0)
if(site<N&&time>0)
{
if(time>=ti[site])
save[site][time]=Max(MaxHappy(site+1,time),
fi[site]+MaxHappy(site+1,time-ti[site]));
else
save[site][time]=MaxHappy(site+1,time);
}
return save[site][time];
}
int Max(int a,int b)
{
if(a<b)
a=b;
return a;
}
  • vijos

展开全文 >>

P1011 清帝之惑之顺治 解题报告

Published on 2009 / 04 / 24

Vijos 上 P1011 清帝之惑之顺治,一个动态规划加记忆化搜索搞定。 有一个 memset 函数,值得学习一下。 贴出代码(防止某些同志只会复制+粘贴,我上传的是截图):

p1011-1

p1011-2

  • vijos

展开全文 >>

P1024 卡布列克圆舞曲

Published on 2009 / 04 / 19

这是我在 Vijos 上做的,我是借鉴了 yzl1117 借鉴 talent123 前辈的程序写成的程序写成的。除了对 sprintf 函数了解了以外,还学到许多东西。

原题地址:http://www.vijos.cn/Problem_Show.asp?id=1024

以下是我改的程序(和他们的相似比很高~~~~~~~~)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
double numble,circle[1000];
double Cal(int n);
double Change(double num);
int Print(int i);
void Subordination();
int main()
{
while(1)
{
if(scanf("%lf",&numble)==-1)
break;
else
Subordination(numble);
}
return(0);
}
double Cal(int n)
{
if(n==0)
return 1;
else
return Cal(n-1)*10;
}
double Change(double num)
{
char ch[150];
int temp;
double max=0,min=0;
sprintf(ch,"%.0f",num);
int i,j;
for(i=0;i<strlen(ch);i++)
for(j=0;j<strlen(ch)-i-1;j++)
if(ch[j]>ch[j+1])
{
temp=ch[j];
ch[j]=ch[j+1];
ch[j+1]=temp;
}
for(i=0;i<strlen(ch);i++)
{
max+=Cal(i)*(ch-'0');
min+=Cal(strlen(ch)-i-1)*(ch-'0');
}
return max-min;
}
int Print(int i)
{
int j;
for(j=0;j<i;j++)
{
if(circle[j]==circle)break;
}
if(j==i)return 0;
else
{
for(;j<i;j++)printf("%.0lf ",circle[j]);
printf("\n");
return 1;
}
}
void Subordination()
{
int i=0;
for(i=0;;i++)
{
circle=numble;
if(Print(i)==1)
break;
else
numble=Change(numble);
}
}
  • vijos

展开全文 >>

« Prev1…141516 Next »
Copyrights © 2009 - 2025 Sink. All Rights Reserved.
Hexo Illya
  • 所有文章
  • 友情链接
  • +1s

tag:

  • ubuntu
  • dns
  • deepin
  • rfc
  • django
  • database
  • work
  • python
  • greenplum
  • postgres
  • how-to
  • linux
  • react
  • firefox
  • nginx
  • vijos
  • go
  • toml
  • tools
  • usaco
  • IPv6
  • gpg

    缺失模块。
    1、请确保node版本大于6.2
    2、在博客根目录(注意不是yilia根目录)执行以下命令:
    npm i hexo-generator-json-content --save

    3、在根目录_config.yml里添加配置:

      jsonContent:
        meta: false
        pages: false
        posts:
          title: true
          date: true
          path: true
          text: false
          raw: false
          content: false
          slug: false
          updated: false
          comments: false
          link: false
          permalink: false
          excerpt: false
          categories: false
          tags: true
    

  • 浮云计算
  • 成成个人学习小站
  • Victor 的自留地
  • amtoaer
  • lxkaka
  • 酷壳CooShell
  • 曜彤.手记

一个人的命运啊,当然要靠自我奋斗,但是也要考虑到历史的行程。

很惭愧,就做了一点微小的工作,谢谢大家。