From 7e503ff793cd0f66bf36569a69974406a837e2d6 Mon Sep 17 00:00:00 2001 From: AK4TRl Date: Tue, 21 Jun 2016 13:22:37 +0800 Subject: [PATCH 1/3] Create HDU 5676 ztr loves lucky numbers.cpp --- AK4TRL/HDU 5676 ztr loves lucky numbers.cpp | 50 +++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 AK4TRL/HDU 5676 ztr loves lucky numbers.cpp diff --git a/AK4TRL/HDU 5676 ztr loves lucky numbers.cpp b/AK4TRL/HDU 5676 ztr loves lucky numbers.cpp new file mode 100644 index 00000000..ce854da0 --- /dev/null +++ b/AK4TRL/HDU 5676 ztr loves lucky numbers.cpp @@ -0,0 +1,50 @@ +//暴力,先把所有情况与处理出来,再根据给出数据判断数字位置 +#include +#include +#include +#include +#include +#include +#include +#include +typedef long long ll; +ll flag[100000], cnt; +void dfs(int len, int mid, int numc, ll num){ + if(numc == len){ + flag[cnt++] = num; + return ; + } + else{ + if(mid > 0) + dfs(len, mid-1, numc + 1, num * 10 + 4); + if(len - numc > mid) + dfs(len, mid, numc + 1, num * 10 + 7); + } + return ; +} +void init(){ + for(int i = 2; i <= 18; i += 2) + dfs(i,i/2,0,0); + std::sort(flag,flag+cnt); +} +int main(){ +#ifdef hantai + freopen("input.txt","r",stdin); + freopen("output.txt","w",stdout); +#endif + cnt = 0; + init(); + int t; + std::scanf("%d",&t); + while(t--){ + ll a; + std::cin >> a; + ll id = std::lower_bound(flag,flag+cnt,a)-flag; + if(a >= 1e18) + puts("44444444447777777777"); + else + std::printf("%lld\n",flag[id]); + } + + return 0; +} From 695cc0742646ca094b4eb5161023039416fd2acd Mon Sep 17 00:00:00 2001 From: AK4TRl Date: Thu, 23 Jun 2016 10:03:13 +0800 Subject: [PATCH 2/3] Create HDU 5672 String.cpp --- AK4TRL/HDU 5672 String.cpp | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 AK4TRL/HDU 5672 String.cpp diff --git a/AK4TRL/HDU 5672 String.cpp b/AK4TRL/HDU 5672 String.cpp new file mode 100644 index 00000000..b6a95128 --- /dev/null +++ b/AK4TRL/HDU 5672 String.cpp @@ -0,0 +1,36 @@ +#include +#include +#include +#include +#include +#include +using namespace std; +typedef long long ll; +int T,k,H[300]; +char s[1000005]; +int main(){ +#ifdef ak4trl + freopen("input.txt","r",stdin); + freopen("output.txt","w",stdout); +#endif + scanf("%d",&T); + while(T--) { + scanf("%s%d",s+1,&k); + int n = strlen(s+1); + memset(H,0,sizeof(H)); + int r = 0,cnt = 0; + ll ans = 0 ; + for(int l = 1;l<=n;l++) { + while(cnt Date: Mon, 27 Jun 2016 09:22:04 +0800 Subject: [PATCH 3/3] =?UTF-8?q?Create=20POJ=203255=20=E6=AC=A1=E7=9F=AD?= =?UTF-8?q?=E8=B7=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...3255 \346\254\241\347\237\255\350\267\257" | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 "AK4TRL/POJ 3255 \346\254\241\347\237\255\350\267\257" diff --git "a/AK4TRL/POJ 3255 \346\254\241\347\237\255\350\267\257" "b/AK4TRL/POJ 3255 \346\254\241\347\237\255\350\267\257" new file mode 100644 index 00000000..3334e1c8 --- /dev/null +++ "b/AK4TRL/POJ 3255 \346\254\241\347\237\255\350\267\257" @@ -0,0 +1,69 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#define INF 0x3f3f3f3f +using namespace std; +const int N = 1001 ; +int tn , n , m , k , tcase = 0 ; + +struct edge{ + int to , cost ; + edge(){} edge(int a , int b) : to(a) , cost(b) {} +} ; +typedef pair pii ; +vector g[5005] ; +int d[5005] , d2[5005] ; + +void dijkstra() +{ + priority_queue , greater > que ; + fill(d,d+n,INF) ; + fill(d2,d2+n,INF) ; + d[0] = 0 ; + que.push(pii(0,0)); + while(!que.empty()) + { + pii p = que.top() ; + que.pop() ; + int v = p.second , td = p.first ; + if(d2[v] < td) + continue ; + for(int i = 0 ; i < g[v].size() ; ++i) + { + edge &e = g[v][i] ; + int td2 = td + e.cost ; + if(d[e.to] > td2) + swap(d[e.to] , td2), que.push(pii(d[e.to] ,e.to)) ; + if(d2[e.to] > td2 && d[e.to] < td2) + d2[e.to] = td2, que.push(pii(d2[e.to] , e.to)) ; + } + } + cout << d2[n-1] << endl ; +} +int main() +{ +#ifdef ONLINEJUDGE_AK4TRl + freopen("input.txt","r",stdin); +#endif + cin >> n >> m ; + int a , b , c ; + for(int i = 0 ; i < m ; ++i) + { + cin >> a >> b >> c ; + g[a-1].push_back(edge(b - 1 , c)) ; + g[b-1].push_back(edge(a - 1 , c)) ; + } + dijkstra() ; + + return 0; +}