250pt:

题意:在二维平面上,给定3种,左转、右转,以及前进一步,的指令序列循环执行,问整个移动过程是否是发散的。

思路:直接模拟一个周期,然后判断1.方向是否和初始时不同 2.是否在原来的点

满足其一便是收敛。具体画个图便明白

code:

 #line 7 "SequenceOfCommands.cpp"
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
using namespace std; #define PB push_back
#define MP make_pair #define REP(i,n) for(i=0;i<(n);++i)
#define FOR(i,l,h) for(i=(l);i<=(h);++i)
#define FORD(i,h,l) for(i=(h);i>=(l);--i) typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<double> VD;
typedef long long LL;
typedef pair<int,int> PII;
const int g[][] = {{, },{,-},{-, },{, }}; class SequenceOfCommands
{
public:
string whatHappens(vector <string> commands)
{
string S = accumulate(commands.begin(), commands.end(), string(""));
int x = , y = , dir = ;
int n = S.size();
for (int i = ; i < n; ++i){
if (S[i] == 'L') dir = (dir + ) % ;
if (S[i] == 'R') dir = (dir + ) % ;
if (S[i] == 'S'){
x += g[dir][];
y += g[dir][];
}
}
if (x == && y == ) return "bounded";
if (dir != ) return "bounded";
return "unbounded";
}
};

500pt:

题意:将圆周 n<= 10^6等分,编号0~n-1,现在上面选取m <= 10^5个点,给定整数a b c,选择的第i个点的下标为(a*a*i+b*i+c)%n,如果已经被选过则选下一个木有被选的点。问这些点能构成多少个直角三角形。

思路:直角三角形必须经过圆心。所以n为奇数必然无解。

否则先求出这m个点。每次求完后标记下,并用并查集加速。

code:

 #line 7 "RightTriangle.cpp"
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
using namespace std; #define PB push_back
#define MP make_pair #define REP(i,n) for(i=0;i<(n);++i)
#define FOR(i,l,h) for(i=(l);i<=(h);++i)
#define FORD(i,h,l) for(i=(h);i>=(l);--i) typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<double> VD;
typedef long long LL;
typedef pair<int,int> PII;
int fa[];
bool vis[]; class RightTriangle
{
public:
int find(int k){
return !vis[k] ? k : fa[k] = find(fa[k]);
}
long long triangleCount(int n, int m, long long a, long long b, long long c)
{
if (n & ) return ;
memset(vis, , sizeof(vis));
for (int i = ; i < n; ++i) fa[i] = (i + ) % n;
for (int i = ; i < m; ++i)
vis[find((a * i * i + b*i +c) % n)] = true;
long long ans = ;
for (int i = ; i < n / ; ++i)
if (vis[i] && vis[i + n / ]) ++ ans;
return ans * (m - );
}
};

SRM473的更多相关文章

随机推荐

  1. IntelliJ idea 的破解

    ·1.破解的jar包下载链接: https://pan.baidu.com/s/1JV6GwguGQNs5pNQtst29Hw  提取码: u2jd 2.安装和破解地址:https://www.cnb ...

  2. iOS.AutoLayout.2.CustomView-with-AutoLayout

    Custom View Which Support AutoLayout 创建支持AutoLayout的Custom View AutoLayout 通过使view更加的自组织来减轻controlle ...

  3. 20172306 《Java程序设计与数据结构》第七周学习总结

    20172306<Java程序设计>第七周学习总结 教材学习内容总结 这一章的标题是继承.主要学习了有关继承的相关知识.其中在这五节中,我学到了以下几点: 1.继承主要表达的是" ...

  4. dede 栏目及子栏目

    结果如图: <ul class="bottom_ul"> {dede:channelartlist } <li><a href="{dede ...

  5. Java的反射技术

    什么是反射机制 Java的反射机制是在运行状态中,对于任意一个类,都能够知道这个类的所有属性和方法:对于任意一个对象,都能调用它的任意属性和方法.这种动态获取信息以及动态调用对象属性和方法的即使称为J ...

  6. [Robot Framework] Robot Framework怎么调试?

    Robot Framework怎么debug? 在eclipse里面安装一个插件,就可以debug robot framework的project. 插件下载地址: https://github.co ...

  7. jmeter脚本录制的两种方式

    完成一次完整的性能测试: 1.创建用户: 2.选择协议(HTTP) 3.使用工具去模拟协议操作(1.手工编写(抓包工具):2.工具自带录制) 4.运行工具进行压力测试

  8. ubuntu系统ftp连接 以及ssh连接

    tfp连接 ssh连接 ubuntu下ssh使用 与 SCP 使用 1 ssh远程登录服务器 ssh username@remote_ip #将username换成自己的用户名,将remote_ip换 ...

  9. 外部javascript形式

    ***.js: /** * 收起或者展开筛选框 */ function filterType(){ $("#filter_box_id").toggle(500); var sha ...

  10. wireshark源码分析二

    一.源代码结构 在wireshark源代码根目录下,可以看到以下子目录: 1)物理结构     其中,epan文件夹负责所有网络协议识别工作,plugins里面存放了wireshark所有插件,gtk ...