以后不好意思放报告就在这记一下心得啦
POJ1083
http://wenku.baidu.com/view/98287f0c844769eae009edf9.html 这个说此题是DP, 我琢磨了一下贪心不就行嘛, 再看了下discuss连贪心都不用.. 将路线的线段压扁后, 设最多的地方有n层, 那么最优解显然不会n, 可以推出必然总是存在至少一个点上有m条线段, 因为每一个点上有多少条线段都是常数, 这显然也是不成立的..
STL好好用 =D swap() max_element()
[cpp]#include <stdio.h>
#include <algorithm>
#include <string.h>
using namespace std;
int main() {
int T,N;
scanf("%d",&T);
while(T–) {
scanf("%d",&N);
int s,t,press[200];
memset(press,0x00,sizeof(press));
for(int i=0;i<N;i++) {
scanf("%d%d",&s,&t);
if(s>t)
swap(s,t);
for(int k=(s-1)>>1;k<=(t-1)>>1;k++)
press[k]++;
}
printf("%d\n",*max_element(press,press+200)*10);
}
return 0;
}[/cpp]
POJ1456
又是DP list上的题目想了想用贪心做了.. 算法没啥难度细节挺恶心, 数据结构又用了位, 感觉思维复杂度和struct差不多, 打出来酷一点..
恶心了有两小时.. 大概是有点困了
[cpp]
#include <stdio.h>
#include <stdlib.h>
int __comp1(const void *a,const void *b) {
return (*(int *)a&((1<<14)-1)) – (*(int *)b&((1<<14)-1));
}
int __comp2(const void *a,const void *b) {
return (*(int *)a>>14) – (*(int *)b>>14);
}
int seqMax(int a[],int from,int to) {
int p=from;
for(int i=from+1;i<=to;i++) {
if((a[p]>>14)<(a[i]>>14))
p=i;
}
int r=(a[p]>>14);
a[p]=a[to];
return r;
}
int main() {
int a[10001],n;
while(1) {
if(scanf("%d",&n)==EOF)
break;
for(int i=0;i<n;i++) {
scanf("%d",a+i);
a[i]<<=14;
int temp;
scanf("%d",&temp);
a[i]+=temp;
}
qsort(a,n,sizeof(int),__comp1);
int edge=-1;
int head=n-1;
int result=0;
for(int i=n-1;i>=0 && head >=0;) {
for(;head>0;head–)
if((a[head-1]&((1<<14)-1))!=edge)
break;
int days=(a[head]&((1<<14)-1))-(head==0?0:(a[head-1]&((1<<14)-1)));
//qsort(a+head,i-head+1,sizeof(int),__comp2); too much time cost, according to the test data
int cut=(i-head+1)<days?(i-head+1):days;
for(int j=0;j<cut;j++)
result+=seqMax(a,head,i–);
head–;
}
printf("%d\n",result);
}
return 0;
}
[/cpp]
POJ 1730
*pow()以后就用double pow(double a,double b)不要多想
*接上面, 算一个数的开房, 可以b=1/n. 需要注意的是a是负数时即使n是奇数, 函数值也是NaN
*判断NaN可以 a!=a 或使用
中的isnan() . a!=a是因为所有带有NaN的逻辑表达式值都为false, a!=a就是!(a==a)
*这道囧题说”The value of x will have magnitude at least 2″(绝对值>=2, 有可能是负的), 重点是”and be within the range of a (32-bit) int”, 但是当时是ISO C90的标准,那时候2^31还是在int型以内的.. 所以2^31要单独考虑或者用long long.. 太囧了阿..
[cpp]
#include <stdio.h>
#include <math.h>
int main() {
while(1) {
long long n;
scanf("%lld",&n);
if(!n)
break;
int max=1;
for(int i=31;i>=2;i–) {
if(n<0 && !(i%2))
continue;
long long __n=(long long)fabs((double)n);
double m=pow((double)__n,(double)1/i);
if(m-(int)m<1E-12||(int)m+1-m<1E-12) {
max=i>max?i:max;
break;
}
}
printf("%d\n",max);
}
return 0;
}
[/cpp]
POJ 1953
就是Fibonacci数列, 推了一下发现a[i] = sum(a[k])+1, k=1..i-2
[cpp]#include <stdio.h>
int main() {
int dp[46][2];
dp[0][0]=1;
dp[0][1]=0;
for(int i=1;i<=45;i++) {
dp[i][0]=dp[i-1][0]+dp[i-1][1];
dp[i][1]=dp[i-1][0];
}
int N;
scanf("%d",&N);
for(int i=1;i<=N;i++) {
int a;
scanf("%d",&a);
printf("Scenario #%d:\n%d\n\n",i,dp[a+1][0]);
}
return 0;
}
[/cpp]
References:
KingMaker Casino Bonus bei Einzahlung toolbarqueries.google.lv
References:
Legiano Casino Zahlungsmethoden http://maps.google.nu/url?q=https://dudoser.com/user/dropbongo52/
References:
Legiano Casino Neukundenbonus https://forum.cmsheaven.org/proxy.php?link=https://telegra.ph/Legiano-casino-login-konto-erstellen-wie-anmelden-06-07-3
References:
KingMaker einzahlungslimit http://www.htcdev.com/
References:
KingMaker einzahlung skrill financial-dictionary.thefreedictionary.com
References:
Legiano Casino Jackpot http://inlinehokej.sh10w2.esports.cz/multimedia/fotografie/33-sk-cernosice-ihc-certi-kladno.html?type=1&url=//commonwiki.space/wiki/Jetzt_online_spielen
References:
Legiano Casino Auszahlungsdauer http://www.nashi-progulki.ru/bitrix/redirect.php?event1=&event2=&event3=&goto=https://roadwiki.site/wiki/Legiano_Casino_verbindet_SocialMediaPlattformen_fr_Deutschland
References:
Legiano Casino Treueprogramm http://reshalkino.ru
References:
KingMaker Casino Einzahlung mit Klarna http://maps.google.sc/
References:
Legiano Casino Mindestauszahlung http://images.google.ge
References:
Hit spin casino http://toolbarqueries.google.st/url?sa=t&url=https://campus.tdea.edu.co/cas/logout?url=https://de.trustpilot.com/review/der-wikinger-shop.de
References:
Hit n spin casino no deposit bonus hezuo.xcar.com.cn
References:
Monro Casino Live Dealer https://www.niann.ru//voffice.lawyers.bh/selinacolebe3
References:
Hitnspin casino mit echtgeld http://redirect.camfrog.com/redirect/?url=https://tiwar.ru/?channelId=298&partnerUrl=de.trustpilot.com/review/der-wikinger-shop.de/
References:
Hit n spin casino no deposit bonus images.google.mw
References:
Monro Casino Spielen https://captcha.2gis.ru/form?return_url=https://url.pixelx.one/scotvalazquez
References:
Hitnspin deutschland ztcmedia.mobie.in
References:
Hitnspin casino spielautomaten https://forexsklad.org
References:
Hitnspin registrierung http://pedigree.setter-anglais.fr/
References:
Hitnspin casino spiele http://scivideoblog.com/
References:
Hitnspin casino willkommensbonus http://cse.google.co.ao/
References:
Hitnspin casino bewertung https://remark-service.ru/go?url=http://forum.xnxx.com/proxy.php?link=https://de.trustpilot.com/review/der-wikinger-shop.de
References:
Hitnspin aktionscode https://www.vs.uni-due.de
References:
Hitnspin casino erfahrungen https://www.playground.ru/
References:
Hit n spin bonus ohne einzahlung dlina.wiki.gwdg.de
References:
Casino hitnspin https://www.rybalka44.ru/forum/go.php?url=aHR0cHM6Ly93d3cuZGl2aW5hZ3JhY2lhLmVkdS5lYy9wcm9maWxlL3doaXR0YWtlcmx6ZHNpdmVydHNlbjMwMjkxL3Byb2ZpbGU
References:
Hit n spin casino online login https://shop-photo.ru:443/go_shou?a:aHR0cDovL2ZwcmludHMuY29tLnVhL3VzZXIvc3Rld3NraWluZzEv
References:
Hitnspin casino kostenlos spielen http://researchesanswered.akamaized.net/__media__/js/netsoltrademark.php?d=liveheadline.space/item/hit-n-spin-deutschland-bonus-800-200-freespins
References:
Hitnspin casino erfahrungen newhydro.ru
References:
Hitnspin free spins http://www.freethesaurus.com/_/cite.aspx?url=http://sub.elfejewelry.com:443/index.php?wheelerclausen777541&word=ramper&sources=hc_thes,wn
References:
Hitnspin casino kundenbewertungen https://blog.fc2.com/?jump=https://qrlinkgenerator.com/jannieelliston
References:
Hitnspin casino bonus stove.ru
References:
Hit n spin casino no deposit bonus https://wiki.opencellid.org
References:
Lollybet Gutschein http://maps.google.mg/url?sa=t&url=https://jaluzion.ru/action.redirect/url/aHR0cHM6Ly9sb2xseWJldC5jb20uZGUv
References:
Lollybet Casino Einzahlung http://hotubi.com
References:
Lollybet Casino Sicherheit https://tulum.ru/catalog/view/theme/quick-view.php?product_id=2702&product_href=http://vurl.com/WEjmX
References:
Lollybet Live Casino postjung.com
References:
Lollybet Casino Aktion maps.google.com.lb
References:
Lollybet Casino Slots images.google.al
References:
Lollybet Casino Zahlungsmethoden http://cse.google.gp/url?sa=i&url=https://actualites.cava.tn/user/friendliquid8/
References:
Lollybet Casino Bonus ohne Einzahlung https://cam7.chaturbate.com/external_link/?url=https://xtuml.org/author/riflemom9/
References:
Hitnspin casino paysafecard clients1.google.mw
References:
Hitnspin casino alternative http://clients1.google.ge/url?q=https://urlscan.io/result/019eb126-f6ae-7669-b820-c01d7a41a06c//
References:
Hit n spin no deposit bonus http://clients1.google.be/
References:
Hitnspin casino ähnliche casinos clients1.google.com.bd
References:
Hit n spin casino deutsch http://cse.google.cl/
References:
Hitnspin casino kostenlos spielen http://images.google.co.ma/url?q=https://www.holycrossconvent.edu.na/profile/kesslerzawfrom5760/profile
References:
Hitnspin casino einzahlung http://clients1.google.ml/
References:
Hitnspin casino erfahrungen http://alagard.ru/bitrix/redirect.php?event1=&event2=&event3=&goto=https://www.haphong.edu.vn/profile/hedevigpihl19753/profile
References:
Pokies net australia payid withdrawal https://git.chalypeng.xyz/staciegarnsey2