USACO Section 1.1PROB Your Ride Is Here

题目传送门 不能提交哦   http://www.nocow.cn/index.php/Translate:USACO/ride

/*
ID: jusonal1
PROG: ride
LANG: C++
*/
#include <iostream>
#include <fstream>
#include <string>
#include <cstdio>
#include <algorithm>
using namespace std;
int n(char a){
    return a - ‘A‘ + 1;
}
int num(string a){
    int ans = 1;
    for(int i = 0;a[i] != ‘\0‘;++i)
        ans = ans*n(a[i])%47;
    return ans;
}
int main ()
{
  ofstream fout("ride.out");
  ifstream fin("ride.in");
  string a,b;
  fin>>a>>b;
  //cin>>a>>b;
  if(num(a) == num(b)) fout<<"GO"<<endl;
  else fout<<"STAY"<<endl;
  return 0;
}
时间: 2024-08-08 05:36:44

USACO Section 1.1PROB Your Ride Is Here的相关文章

USACO Section 1.1 Your Ride Is Here

原题: Your Ride Is Here It is a well-known fact that behind every good comet is a UFO. These UFOs often come to collect loyal supporters from here on Earth. Unfortunately, they only have room to pick up one group of followers on each trip. They do, how

USACO Section 2.1 Healthy Holsteins

/* ID: lucien23 PROG: holstein LANG: C++ */ #include <iostream> #include <fstream> #include <vector> using namespace std; bool compFun(int x, int y) { int temp, i = 0; while (true) { temp = 1 << i; if (temp&x > temp&y) {

USACO Section 2.2 Party Lamps

/* ID: lucien23 PROG: lamps LANG: C++ */ /* * 此题的技巧之处就是需要注意到任何button只要按下2的倍数次就相当于没有按 * 所以其实只需要考虑4个按钮,每个按钮是否被有效按下过一次就好 * 直接使用枚举法,一共只有2^4=16种情况 * 对于每种情况需要知道被按下的有效次数(也就是被按下过的按钮数),必须满足 * (C-有效次数)%2=0才行,这样其他次数才能视为无效 * 然后验证各种情况是否符合要求,将符合要求的情况按序输出即可 */ #inc

USACO Section 2.2 Runaround Numbers

/* ID: lucien23 PROG: runround LANG: C++ */ #include <iostream> #include <fstream> #include <cstring> using namespace std; int main() { ifstream infile("runround.in"); ofstream outfile("runround.out"); if(!infile || !

USACO Section 2.2 Preface Numbering

/* ID: lucien23 PROG: preface LANG: C++ */ #include <iostream> #include <fstream> #include <string> #include <map> using namespace std; int main() { ifstream infile("preface.in"); ofstream outfile("preface.out")

USACO 1.1.1 YOUR RIDE IS HERE

众所周知,在每一个彗星后都有一只UFO.这些UFO时常来收集地球上的忠诚支持者.不幸的是,他们的飞碟每次出行都只能带上一组支持者.因此,他们要用一种聪明的方案让这些小组提前知道谁会被彗星带走.他们为每个彗星起了一个名字,通过这些名字来决定这个小组是不是被带走的那个特定的小组(你认为是谁给这些彗星取的名字呢?).关于如何搭配的细节会在下面告诉你:你的任务是写一个程序,通过小组名和彗星名来决定这个小组是否能被那颗彗星后面的UFO带走. 小组名和彗星名都以下列方式转换成一个数字:最终的数字就是名字中所

USACO CHAPTER 1 1.1 Ride 水题

水题,主要是学习文件输入输出. 1 /* 2 ID: ijustwa1 3 LANG: C++ 4 TASK: ride 5 */ 6 #include<cstdio> 7 #include<cstring> 8 9 using namespace std; 10 11 const int base=16; 12 const int mod=47; 13 14 char s[10]; 15 char t[10]; 16 17 int main() 18 { 19 FILE *fin

USACO Section 2.1 Sorting a Three-Valued Sequence

/* ID: lucien23 PROG: sort3 LANG: C++ */ #include <iostream> #include <fstream> #include <vector> #include <algorithm> using namespace std; void exchange(int nums[], int begin, int end, int N, int x); int sum = 0; int main() { ifst

[IOI1996] USACO Section 5.3 Network of Schools(强连通分量)

nocow上的题解很好. http://www.nocow.cn/index.php/USACO/schlnet 如何求强连通分量呢?对于此题,可以直接先用floyd,然后再判断. ---------------------------------------------------------------------------------- #include<cstdio> #include<iostream> #include<algorithm> #includ