链接:夜间活动

昨天的比赛好郁闷.......倒不是因为题目......在快要比赛的时候突然所有的网站都进不去了.......改了半天的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. HTML5下通过response header解决跨域AJAX cookie的问题

    ajax: 通过给Response Header添加Access-Control-Allow-Origin:*  来解决跨域请求,*代表允许所有的跨域请求,或者把*换成指定的域名 cookie: 服务 ...

  3. Mongodb FAQ 存储(storage)篇

    1.什么是内存映射文件(memory mapped files)? 内存映射文件是操作系统通过调用函数mmap()创建的一个放在内存中的一个数据文件.这种文件可以当做一个从零开始的内存或者数组,你可以 ...

  4. 【弱省胡策】Round #5 Handle 解题报告

    这个题是我出的 sb 题. 首先,我们可以得到: $$A_i = \sum_{j=i}^{n}{j\choose i}(-1)^{i+j}B_j$$ 我们先假设是对的,然后我们把这个关系带进来,有: ...

  5. [转载]C# 多选功能(checkedListBox控件)

    // 全选; private void btn_allSelected_Click(object sender, EventArgs e) { //this.CheckedListBox1.Check ...

  6. 执行config文件时,config.log中报错xcrun: error: active developer path ("/Applications/Xcode.app/Contents/Developer") does not exist, use xcode-select to change

    执行 sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer 即可解决.

  7. How to Run Node.js with Express on Mobile Devices

    We released a JXcore plugin for Apache Cordova recently and in this article I will show how to run a ...

  8. StatsD!次世代系统监控的核心

    在互联网业务蒸蒸日上的今时今日,系统架构日渐复杂,随着软件产品和工程团队的变革,许多开源的监控工具应运而生,其中有一些相当出名,比如 Zabbix.Nagios 还有 StatsD.也有一些问题被大家 ...

  9. POJ 2942 Knights of the Round Table(双连通分量)

    http://poj.org/problem?id=2942 题意 :n个骑士举行圆桌会议,每次会议应至少3个骑士参加,且相互憎恨的骑士不能坐在圆桌旁的相邻位置.如果意见发生分歧,则需要举手表决,因此 ...

  10. ASP.NET MVC 入门介绍 (上)

    MVC模式 MVC模式是一种软件架构模式.它把软件系统分为三个部分:模型(Model),视图(View)和控制器(Controller).MVC模式最早由Trygve Reenskaug在1974年提 ...