2018-2019 ACM-ICPC, Asia Jiaozuo Regional Contest

A、A - Xu Xiake in Henan Province

就直接看有几个不是0的

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <unordered_map>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <stack>
#include <set>
#pragma GCC optimize(3 , "Ofast" , "inline")
using namespace std ;
#define ios ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0)
#define x first
#define y second
typedef long long ll ;
const double esp = 1e-6 , pi = acos(-1) ;
typedef pair<int , int> PII ;
const int N = 1e6 + 10 , INF = 0x3f3f3f3f , mod = 1e9 + 7;
ll in()
{
  ll x = 0 , f = 1 ;
  char ch = getchar() ;
  while(!isdigit(ch)) {if(ch == '-') f = -1 ; ch = getchar() ;}
  while(isdigit(ch)) x = x * 10 + ch - 48 , ch = getchar() ;
  return x * f ;
}
int main()
{
  int t = in() ;
  while(t --) {
    int ans = 0 ;
    for(int i = 1 , x ; i <= 4 ;i ++ )
     x = in() , ans += x != 0 ;
    if(ans == 0) puts("Typically Otaku") ;
    else if(ans == 1) puts("Eye-opener") ;
    else if(ans == 2) puts("Young Traveller") ;
    else if(ans == 3) puts("Excellent Traveller") ;
    else puts("Contemporary Xu Xiake") ;
  }
  return 0 ;
}
/*
*/

D - Keiichi Tsuchiya the Drift King

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <unordered_map>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <stack>
#include <set>
#pragma GCC optimize(3 , "Ofast" , "inline")
using namespace std ;
#define ios ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0)
#define x first
#define y second
typedef long long ll ;
const double esp = 1e-6 , pi = acos(-1) ;
typedef pair<int , int> PII ;
const int N = 1e6 + 10 , INF = 0x3f3f3f3f , mod = 1e9 + 7;
ll in()
{
  ll x = 0 , f = 1 ;
  char ch = getchar() ;
  while(!isdigit(ch)) {if(ch == '-') f = -1 ; ch = getchar() ;}
  while(isdigit(ch)) x = x * 10 + ch - 48 , ch = getchar() ;
  return x * f ;
}
void work()
{
    double a , b , r , d ;
    cin >> a >> b >> r >> d ;
    double c = sqrt((a + r) * (a + r) + b * b)  ;
    double t = atan(1.0 * b / (a + r)) ;
    double res = max(0 * 1.0 , t - (d * pi / 180)) ;
    printf("%.12lf
" , c * cos(res) - r) ;
    return ;
}
int main()
{
  int t = in() ;
  while(t --) work() ;
  return 0 ;
}
/*
*/

E - Resistors in Parallel

import java.math.BigInteger;
import java.util.Scanner;
 
public class Main{
	
	final static int N = 1010100 ;
	static int prime[] , vis[] , tot = 0 ;
	
	static BigInteger gcd(BigInteger a , BigInteger b) {
		if(b == BigInteger.ZERO)  return a ;
		return gcd(b ,  a.mod(b)) ;
	}
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in) ;
		prime = new int[N] ;
		vis = new int[N] ;
		for(int i = 1; i < N ;i ++ ) vis[i] = 0 ;
		for(int i = 2; i < N ;i ++ ) {
			if(vis[i] == 0) prime[++ tot] = i ;
			for(int j = 1; j <= tot && i * prime[j] < N ;j ++ ) {
				vis[i * prime[j]] = 1 ;
				if(i % prime[j] == 0) break ;
			}
		}
		int t = cin.nextInt() ;
		while((t --) != 0 ){
			BigInteger n = cin.nextBigInteger() ;
			BigInteger fz = BigInteger.ONE , fm = BigInteger.ONE ;
		    for(int i = 1; i <= tot ;i ++ ) {
		    	if(fm.multiply(BigInteger.valueOf(prime[i])).compareTo(n) <= 0) {
		    		
		    		fm = fm.multiply(BigInteger.valueOf(prime[i])) ;
		    		fz = fz.multiply(BigInteger.valueOf(1 + prime[i])) ;
		    	}else break ;
		    }
    		BigInteger GCD = gcd(fm , fz) ;
    		fm = fm.divide(GCD) ;
    		fz = fz.divide(GCD) ;
    		System.out.println(fm + "/" + fz);
		}
	}
	
}

F - Honeycomb

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <unordered_map>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <stack>
#include <set>
#pragma GCC optimize(3 , "Ofast" , "inline")
using namespace std ;
#define ios ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0)
#define x first
#define y second
typedef long long ll ;
const double esp = 1e-6 , pi = acos(-1) ;
typedef pair<int , int> PII ;
const int N = 1e6 + 10 , INF = 0x3f3f3f3f , mod = 1e9 + 7;
ll in()
{
  ll x = 0 , f = 1 ;
  char ch = getchar() ;
  while(!isdigit(ch)) {if(ch == '-') f = -1 ; ch = getchar() ;}
  while(isdigit(ch)) x = x * 10 + ch - 48 , ch = getchar() ;
  return x * f ;
}
int d[6][2] = {-2 , 0 , -1 , 3 , 1 , 3 , 2 , 0 , 1 , -3 , -1 , -3} ;
char s[4010][6010] ;
struct node {
  int x , y , dis ;
};
void work(){
  int n = in() , m = in() ;
  queue<node> q ;
  for(int i = 0 ;i < 4 * n + 3 ;i ++ )
    {
      gets(s[i]) ;
      for(int j = 0 ;j < 6 * m + 3 ;j ++ ) {
        if(s[i][j] == 'S') q.push({i , j , 1}) , s[i][j] = '*' ;
      }
    }
    int ans = 0 ;
    while(q.size()) {
      auto t = q.front() ; q.pop() ;
      for(int i = 0 ;i < 6 ;i ++ ) {
        int tx = t.x + d[i][0] , ty = t.y + d[i][1] ;
        if(s[t.x][t.y] == 'T') {
          printf("%d
" , t.dis) ;
          return ;
        }
        ans ++ ;
        if(ans > 5e6) break ;
        if(tx < 0 || ty < 0 || tx >= 4 * n + 3 || ty >= 6 * m + 3 || s[tx][ty] != ' ') continue ;
        int ttx = t.x + 2 * d[i][0] , tty = t.y + d[i][1] * 2 ;
        if(ttx < 0 || tty < 0 || ttx >= 4 * n + 3 || tty >= 6 * m + 3 || s[ttx][tty] == '*') continue ;
        if(s[ttx][tty] != 'T') s[ttx][tty] = '*' ;
        q.push({ttx , tty , t.dis + 1}) ; 
      }
    }
    puts("-1") ;
    return ;
}
int main()
{
  int n ;
  scanf("%d" , &n) ;
  while(n --) work() ;
  return 0 ;
}
/*
*/

I - Distance

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <unordered_map>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <stack>
#include <set>
#pragma GCC optimize(3 , "Ofast" , "inline")
using namespace std ;
#define ios ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0)
#define x first
#define y second
typedef long long ll ;
const double esp = 1e-6 , pi = acos(-1) ;
typedef pair<int , int> PII ;
const int N = 1e6 + 10 , INF = 0x3f3f3f3f , mod = 1e9 + 7;
ll in()
{
  ll x = 0 , f = 1 ;
  char ch = getchar() ;
  while(!isdigit(ch)) {if(ch == '-') f = -1 ; ch = getchar() ;}
  while(isdigit(ch)) x = x * 10 + ch - 48 , ch = getchar() ;
  return x * f ;
}
ll a[N] ;
void work()
{
  ll n = in() ;
  for(int i = 2; i <= n ;i ++ ) a[i] = in() , a[i] += a[i - 1] ;
  ll ans = 0 , res = 0 , l = 0 , r = n + 1 ;
  for(int i = 1; i <= n ;i ++ ) {
    if(i % 2) {
      l ++ ;
      ans += res ;
    }else {
      r -- ;
      res += a[r] - a[l] ;
      ans += res ;
    }
    printf("%lld%c" , ans , i == n ? '
' : ' ') ;
  }
}
int main()
{
  int t = in() ;
  while(t --) work() ;
  return 0 ;
}
/*
*/
原文地址:https://www.cnblogs.com/spnooyseed/p/13281136.html