首页 > 其他 > 详细

2019 年百度之星·程序设计大赛 - 初赛一

时间:2019-08-18 21:58:43      阅读:103      评论:0      收藏:0      [点我收藏+]

1001

#pragma comment(linker, "/STACK:36777216")

#include <bits/stdc++.h>

#define REP(i,n) for(int i=0;i<int(n);++i)
#define FOR(i,a,b) for(int i=int(a);i<int(b);++i)
#define DWN(i,b,a) for(int i=int(b);i>=int(a);--i)

/// type define
typedef double DB;
typedef long long LL;
typedef std::vector<int>VI;
typedef std::vector<LL>VLL;
typedef std::pair<int, int>PII;
typedef std::pair<LL, LL>PLL;
typedef std::vector<PII >VPII;

/// const
static const double eps = 1e-8;
static const double pi = acos(-1.0);
static const int inf = 0x3f3f3f3f;
static const LL INF = 0x3f3f3f3f3f3f3f3f;

/// common statement
#define PB push_back
#define MP std::make_pair
#define fi first
#define se second

/****************************************************************/

const int maxn = 2e6 + 7;
const LL MOD = 1e9 + 7;

int a[maxn],b[maxn];

void solve() {
  /*********** start your code here. ************/
  int n;
  std::cin >> n;
  REP(i,n) std::cin >> a[i];
  REP(i,n) std::cin >>b[i];
  for(int i = n-1; i >= 0; --i) {
    int x = a[i],y = b[i];
    if(a[i] || b[i]) {
      if(!x)
        puts("0/1");
      else if(!y)
        puts("1/0");
      else {
        int z = std::__gcd(x,y);
        x /= z,y /= z;
        std::cout << x << "/" << y << "\n";
      }
      break;
    }
  }
}

void init() {

}

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  init();
  int T;
  std::cin >>T;
  while(T--)
    solve();
  return 0;
}

1005

#pragma comment(linker, "/STACK:36777216")

#include <bits/stdc++.h>

#define REP(i,n) for(int i=0;i<int(n);++i)
#define FOR(i,a,b) for(int i=int(a);i<int(b);++i)
#define DWN(i,b,a) for(int i=int(b);i>=int(a);--i)

/// type define
typedef double DB;
typedef long long LL;
typedef std::vector<int>VI;
typedef std::vector<LL>VLL;
typedef std::pair<int, int>PII;
typedef std::pair<LL, LL>PLL;
typedef std::vector<PII >VPII;

/// const
static const double eps = 1e-8;
static const double pi = acos(-1.0);
static const int inf = 0x3f3f3f3f;
static const LL INF = 0x3f3f3f3f3f3f3f3f;

/// common statement
#define PB push_back
#define MP std::make_pair
#define fi first
#define se second

/****************************************************************/

const int maxn = 2e6 + 7;
const LL MOD = 1e9 + 7;

LL C(LL x){
  LL step[] = {3,4,3,1,6,1};
  LL b[] = {0,1,1,0,3,0};

    return b[x%6]+x/6*step[x%6];
}

void solve() {
  /*********** start your code here. ************/
  LL n;std::cin >>n;
  std::cout << C(n) << "\n";
}



void init() {

}

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  //init();
  int T;
  std::cin >>T;
  while(T--)
    solve();
  return 0;
}

2019 年百度之星·程序设计大赛 - 初赛一

原文:https://www.cnblogs.com/Forgenvueory/p/11374092.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!