Time of Update: 2018-12-05
/** 大數乘法 **/#include<stdio.h>#include<string.h>#define N 500int multy[1000]; //一千位以下的大數void multiplyer(char *a,char *b){ int i,j,num,tem,h; char k; memset(multy,0,sizeof(multy)); for(i=strlen(a)-1; i>=0; i--)
Time of Update: 2018-12-05
描述:後三位用冪模數來做,前三位用log10來做#include <cstdio>#include <cmath>int pow_mode(int n,int m){ if(m==1) return n; int c=pow_mode(n,m/2); int d=c*c%1000; if(m%2==1) d=d*n%1000; return d;}int main(){ // freopen("a.txt","r",stdin);
Time of Update: 2018-12-05
描述:這道題雖然是開方題,可是資料量卻相當的大,可達1000位,不得不用大數來做#include <cstdio>#include <cstring>int n,m,flag,t;char s[1010],v[1010];int sum[1010],p[1010];int l_sum,l_p;bool com(){ for(int i=0; i<l_sum; ++i) if(sum[i]>p[i]) return 0;
Time of Update: 2018-12-05
#include <cstdio>#include <cmath>#include <cstring>int main(){ int i,j,count,k,num[10]; double x[5050],y[5050],z[5050]; double temp; memset(x,0,sizeof(x)); memset(y,0,sizeof(y)); memset(z,0,sizeof(z));
Time of Update: 2018-12-05
貪心,M在保證與N做OR運算的結果最大的基礎上,使M的值最小。可以先將上界和下界都轉化為二進位,先確定M的最高位,M的最高位可以從u的最高位開始試(理由很簡單),再依次確定之後的數字,每個數字盡量保證與N的二進位相應位置的數字互補(如果N的二進位的某一位是
Time of Update: 2018-12-05
第一次做二叉樹的題,參考了某大神的代碼,充分領略到大神遞迴的境界,光研究他的代碼就花了好幾個小時,還看了cin.ignore(),cin.clear(),cin.fail()以及cin.sync()幾個cin流的實質和妙用,完全連指標鏈表都沒用只用遞迴就把此題給A掉了,受益不少啊~~~代碼如下:#include<iostream>#include<cstring>#include<cstdlib>#include<cstdio>#include&l
Time of Update: 2018-12-05
Matrix SearchingTime Limit: 10 Seconds Memory Limit: 32768 KBGiven an n*n matrix A, whose entries Ai,j are integer numbers ( 1 <= i <= n, 1 <= j <= n ). An operation FIND the minimun number in a given ssub-matrix.InputThe first line
Time of Update: 2018-12-05
曾經放了好久的題,今天A掉了,其實就是推公式了,唯一覺得被坑了就是在windows下long
Time of Update: 2018-12-05
兩個數列排序後進行比較,如果完全相同就輸出“YES”,否則輸出“NO”。代碼如下:#include<iostream>#include<cstring>#include<cstdlib>#include<cstdio>#include<cmath>#include<string>using namespace std;int n_cmp(const void *a,const void *b){ return
Time of Update: 2018-12-05
/** 大數加法 **/#include<stdio.h>#include<string.h>void add(char *a,char *b) // (a += b 且 a的長度大於b的長度){ int i,j; for(i=strlen(a)-1,j=strlen(b)-1; j>=0; j--,i--) a[i]=a[i]+b[j]-'0'; //每一位的數字相加 for(i=strlen(a)-1;
Time of Update: 2018-12-05
當今世界智商最高十大天才1.Stephen William Hawking(斯蒂芬·威廉·霍金) 今年70歲,智商160。他或許是這個榜單上最令人熟知的人。有關他的介紹太多太多,被譽為繼愛因斯坦之後世界上最著名的科學思想家和最傑出的理論物理學家,被譽為“宇宙之王”Stephen William Hawking 2.Kim
Time of Update: 2018-12-05
最近這一段時間,qq旋風中心的分享按鈕很離奇地消失了,這讓我們這些準備刷積分升級到八級從而獲得免費離線空間的人很是苦惱,不過“天無絕人之路”,這篇文章協助你找回失去的分享按鈕! 用google瀏覽器示範一下! 無意中看資源分享中心原始碼發現了這個: 然後就簡單了,我們先隨便點開一個資源分享中心! 就拿他做實驗了! 然後點F12開啟審查元素! 點開<div class="div_bg">…</div>
Time of Update: 2018-12-05
#include <iostream>#include <cstdlib>using namespace std;int main(){ long long int n,i,count; cin>>n; while(n--) { cin>>count; if(count==0)cout<<"3"<<endl; else {
Time of Update: 2018-12-05
/** 大數(高精度)求冪 **/ //輸入兩個數字 m(可以帶小數點),n,求m的n次方#include<stdio.h>#include<string.h>#include<stdlib.h>char multiply[1000];void multiplyer(char *a,char *b) //實質上就是倆個整型大數的乘法{ int i,j,num,tem; int multy[1000]= {0};
Time of Update: 2018-12-05
開始用的回溯TLE了,後來改用全排列+DFS AC。代碼如下:(0.728s):#include <iostream>#include <algorithm>#include <cstring>#include <cstdlib>#include <cstdio>#include <cmath>using namespace std;int a[5], flag;void solve(int cur, int sum){
Time of Update: 2018-12-05
杭州網路賽的題,可以假設殺掉一個敵人後,劍落在地上,以後還可以撿起來,這樣問題就可以簡化不少。/** 貪心題,倆種方式,一種優先考慮bi不為0的情況,因為這樣可以造成不消耗耐久連續殺人;一種優先考慮,bi為0的情況,比如特殊資料:input:5 81 02 02 03 06 1output:4 83 7 或 3 8(為錯誤答案)只考慮bi為0的個體,比先考慮bi不為0的情況,殺的人要多。倆種方案最後比較取出最有解。**/#include <stdio.h>#include
Time of Update: 2018-12-05
/** 大數累加 **/#include<stdio.h>#include<string.h>#define N 1000int sum[N+1]= {0}; // 對於大數的累加來說,開一個int型的數組存數字比開字元型的數組操作起來要更加簡單易用void SumAdd(char *a){ int i,j; for(i=N,j=strlen(a)-1; j>=0; j--,i--) sum[i]+=a[j]-'0';
Time of Update: 2018-12-05
/** 大數除法與求餘 **///這個是uva上的一個題,本身寫的那個比較繁瑣,借鑒了一些其他人的方法 .../***這個題大意為輸入兩個數和一個符號( '/' or ''% ),求除法或是求餘(其中除數是n滿足 0<n<231),例: 輸入為:110 / 10099 % 10輸出為:19***/ 代碼如下:#include<iostream>#include<cstdio>#include<cstring>using namespace
Time of Update: 2018-12-05
描述:用歐拉Function Compute出1~n中所有互質的數#include <cstdio>#include <cstring>int v[50010],sum[50010];void solve(){ memset(v,0,sizeof(v)); sum[0]=0,v[1]=1; for(int i=2; i<=50000; ++i) if(!v[i]) for(int j=i; j<=50000; j+=i)
Time of Update: 2018-12-05
描述:這個需要改用新的演算法,要不然會逾時,從網上找到了一種解決方案: LCS的nlogn演算法就是退化成LIS,LIS nlogn的演算法,就是LCS的時間複雜度。這個我引用某集訓的論文,簡單的講講。設序列A,B。記序列A中各個元素在B中的位置(降序排列),然後按照A中的的位置依次求出A的最長上升子序列。 例如:例如:有A={a,b,a,c,x},B={b,a,a,b,c,a}則有a={6,3,2},b={4,1},c={5};x=/;(注意降序排列)