链接:夜间活动

昨天的比赛好郁闷.......倒不是因为题目......在快要比赛的时候突然所有的网站都进不去了.......改了半天的DNS & IP......比赛都比了1个多小时才进去.....都不想做题了= =|||

A.POJ 3210     Coins

这道题感觉似曾相识......貌似很久以前做过= =

其实仔细想一下,题目并不难~若n为偶数的话,那么"偶正+偶负"翻转的一定是偶数次;而"奇正+奇负"翻转的一定是奇数次~故没有确定的最少次数~

但是,若n为奇数的话,是"奇正+偶负"或"偶正+奇负",翻转的都是偶数次~故存在确定的最少次数!

代码:

 #include <iostream>
#include <cstdio>
using namespace std; int main()
{
int n;
while(scanf("%d",&n),n)
{
if(n%==)
printf("No Solution!\n");
else
printf("%d\n",n-);
}
return ;
}

//memory:164KB  time:16ms

B.HDU 4506     小明系列故事――师兄帮帮忙

此处求k^t时要采用反复平方法(快速幂)【该方法在另一篇博客里讲的有~链接】,否则会TLE~

代码:

 #include <iostream>
#include <cstdio>
#include <cstring>
using namespace std; #define M 1000000007
int T,i;
__int64 a[],b[];
__int64 n,t,k; __int64 Pow(__int64 x,__int64 n) //快速幂~
{
__int64 ret=,s=x;
while()
{
if(n&)
ret=(ret%M*s%M)%M;
if(n>>=)
s=(s%M*s%M)%M;
else
break;
}
return ret;
} int main()
{
scanf("%d",&T);
while(T--)
{
scanf("%I64d%I64d%I64d",&n,&t,&k);
k=Pow(k,t);
t=t%n; //因为t很有可能会大于n,故这一步很重要!!!!
for(i=;i<n;i++)
scanf("%I64d",&a[i]);
for(i=t;i<n;i++)
b[i]=(a[i-t]%M*k)%M;
for(i=;i<t;i++)
b[i]=(a[i+n-t]%M*k)%M;
for(i=;i<n-;i++)
printf("%I64d ",b[i]);
printf("%I64d\n",b[n-]);
}
return ;
}

//memory:428KB   time:46ms

C.HDU 2546     饭卡

代码:

 #include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std; int main()
{
int n,a[],f[],m;
while(scanf("%d",&n),n)
{
for(int i=;i<n;i++)
scanf("%d",&a[i]);
sort(a,a+n);
scanf("%d",&m);
if(m>=)
{
memset(f,,sizeof(f));
for(int i=;i<n-;i++)
for(int j=m-;j>=a[i];j--)
if(f[j-a[i]]+a[i]>f[j] && f[j-a[i]]+a[i]<=m-)
f[j]=f[j-a[i]]+a[i];
printf("%d\n",m-f[m-]-a[n-]);
}
else
printf("%d\n",m);
}
return ;
}

D.HDU 1026     Ignatius and the Princess I

......Loading......

8-13-Exercise的更多相关文章

  1. MIT 6.828 JOS学习笔记13 Exercise 1.10

    Lab 1 Exercise 10 为了能够更好的了解在x86上的C程序调用过程的细节,我们首先找到在obj/kern/kern.asm中test_backtrace子程序的地址, 设置断点,并且探讨 ...

  2. 12/13 exercise

    gcc -[cog] gcc   pro1.o   pro2.o      //create a executable file x.out if unnamed

  3. [未完成]关于Eclipse4RCP书中内容总结

    原文地址http://www.vogella.com/tutorials/EclipseRCP/article.html Table of Contents 1. Eclipse 4 1.1. Wha ...

  4. DTrace to Troubleshoot Java Native Memory Problems

    How to Use DTrace to Troubleshoot Java Native Memory Problems on Oracle Solaris 11 Hands-On Labs of ...

  5. BEC listen and translation exercise 13

    The old lady sits on a mobile chair every morning. He got a large fortune when his father died, but ...

  6. MIT 6.828 JOS学习笔记5. Exercise 1.3

    Lab 1 Exercise 3 设置一个断点在地址0x7c00处,这是boot sector被加载的位置.然后让程序继续运行直到这个断点.跟踪/boot/boot.S文件的每一条指令,同时使用boo ...

  7. Stanford coursera Andrew Ng 机器学习课程编程作业(Exercise 1)

    Exercise 1:Linear Regression---实现一个线性回归 在本次练习中,需要实现一个单变量的线性回归.假设有一组历史数据<城市人口,开店利润>,现需要预测在哪个城市中 ...

  8. C# Development 13 Things Every C# Developer Should Know

    https://dzone.com/refcardz/csharp C#Development 13 Things Every C# Developer Should Know Written by ...

  9. CMSC 216 Exercise #5

    CMSC 216 Exercise #5 Spring 2019Shell Jr (”Shellito”) Due: Tue Apr 23, 2019, 11:30PM1 ObjectivesTo p ...

  10. 软件测试:3.Exercise Section 2.3

    软件测试:3.Exercise Section 2.3 /************************************************************ * Finds an ...

随机推荐

  1. 几种C#实现播放声音的方法

    在这里介绍使用C#实现播放声音的几种方法,都是利用组件等方法来实现的,有兴趣的话可以看下. 第一种是利用DirectX 1.安装了DirectX SDK(有9个DLL文件).这里我们只用到MicroS ...

  2. makefile懒人版(单个文件编译)

    .PHONY:clean all CC=gcc CFLAGS=-Wall -g ###replace your bin BIN=1 2 3 4 all:$(BIN) %.o:%.c $(CC) $(C ...

  3. failed with: java.lang.NullPointerException

    failed with: java.lang.NullPointerException 需要在nutch的配置文件 'conf/nutch-site.xml'. 里设置如下,不然就报上面的错误了. 当 ...

  4. 织梦dede_archives文章主表详细介绍

    dede_archives文章主表,存放着各频道文章的主要信息,比如创建时间,所属栏目,所属频道,作者等详细的信息.     ID int(11) 自动编号typeid int(11) 所属主栏目编号 ...

  5. CV牛人牛事简介之一

    CV牛人牛事简介之一 [论坛按] 发帖人转载自:http://doctorimage.cn/2013/01/01/cv-intro-niubility/#6481970-qzone-1-83120-8 ...

  6. UIWebView 与 JS 交互(1):Objective-C 调用 Javascript

    众所周知,随着硬件水平的发展,HTML5 与原生 APP 性能差距不断缩小,正在互联网科技领域扮演者越来越重要的角色.作为一种能很大程度上节约成本的技术方案,通过 HTML5 及 JS 实现的跨平台技 ...

  7. 类型<T> where T:class的用法

    public void Delete<T>(List<T> EntityList) where T : class, new() 就是说T必须是一个类(class)类型,不能是 ...

  8. 将手机micro USB口转换为USB type C连接器的低成本方案

    我们知道USB IF提出的type C连接器的终极目标是统一各种USB 接口. 尽管USB 3.0在PC市场上发展的风生水起,但是由于USB 3.0对手机4G LTE的EMI和RFI干扰,导致市场上除 ...

  9. Delphi中一些DLL的运用(要传递Application和Screen,似乎还忘了传递提示控件)

    dll 调用部分: {****************************************************************} { } { Project: DllDebug ...

  10. IPv6 tutorial – Part 5: Address types and global unicast addresses

    https://4sysops.com/archives/ipv6-tutorial-part-5-address-types-and-global-unicast-addresses/ In my ...