Sichuan 2017 FSimple Algebra(打表)
来源:互联网 发布:10年 知乎 编辑:程序博客网 时间:2024/06/05 01:03
F. Simple Algebra
Given function f(x, y) = ax2 + bxy + cy2
, check if f(x, y) ≥ 0 holds for all x, y ∈ R.
Input
The input contains zero or more test cases and is terminated by end-of-file.
Each test case contains three integers a, b, c.
• −10 ≤ a, b, c ≤ 10
• The number of tests cases does not exceed 104
.
Output
For each case, output “Yes” if f(x, y) ≥ 0 always holds. Otherwise, output “No”.
Sample Input
1 -2 1
1 -2 0
0 0 0
Sample Output
Yes
No
Yes
题意:对于输入 的a,b,c,是否对于任意的x,y(x,y∈R)均满足f(x,y)>=0,满足输出Yes,否则输出No。
题解:打表,本地check完,将表交上去。
打表主要注意的几点:
1:表一定要打完(即后面要return 0,判断是否打完)
2:每个输出后加一个“,”,方便数组赋值。
3:数组大小要开好,计算方便。
打表:
#include<iostream>#include<stdio.h>#include<stdlib.h>#include<string.h>#include<vector>#include<queue>#include<algorithm>#include<map>using namespace std;typedef long long int ll;typedef pair<int,int>pa;const int N=2e5+10;const int MOD=1e9+7;const ll INF=1e18;int read(){ int x=0; char ch = getchar(); while('0'>ch||ch>'9')ch=getchar(); while('0'<=ch&&ch<='9') { x=(x<<3)+(x<<1)+ch-'0'; ch=getchar(); } return x;}/************************************************************/int solve(int a,int b,int c){ for(int i=-1000;i<=1000;i++) { for(int j=-1000;j<=1000;j++) { if(a*i*i+b*i*j+c*j*j<0) { return 0; } } } return 1;}int main(){ // freopen("in.txt","r",stdin); freopen("out.txt","w",stdout); for(int a=-10;a<=10;a++) { for(int b=-10;b<=10;b++) { for(int c=-10;c<=10;c++) { if(solve(a,b,c)==1) printf("1,"); else printf("0,"); } } } return 0;}
代码:
#include<iostream>#include<stdio.h>#include<stdlib.h>#include<string.h>#include<vector>#include<queue>#include<algorithm>#include<map>using namespace std;typedef long long int ll;typedef pair<int,int>pa;const int N=2e5+10;const int MOD=1e9+7;const ll INF=1e18;int read(){ int x=0; char ch = getchar(); while('0'>ch||ch>'9')ch=getchar(); while('0'<=ch&&ch<='9') { x=(x<<3)+(x<<1)+ch-'0'; ch=getchar(); } return x;}int x,y,z;/************************************************************/int ans[21][21][21]={"将打好的表存到这"};int main(){ while(~scanf("%d%d%d",&x,&y,&z)) { if(ans[x+10][y+10][z+10]==1) puts("Yes"); else puts("No"); }}
阅读全文
0 0
- Sichuan 2017 FSimple Algebra(打表)
- 2015 Sichuan Province Contest (Carries)
- 代数(Algebra)的理解
- 2017 SiChuan collegiate programming contest 训练总结 【持续更新中】
- Sichuan University Programming Contest 2013 Final (singal)E题
- 2017四川省赛F题Simple Algebra
- 数据挖掘-目录-线性代数( linear algebra)
- UVA 10655 Contemplation! Algebra(矩阵乘法)
- Linear Algebra相关知识总结(1)
- 高中数学? (打表)
- Harmonic Number (数组打表(跳跃打表))
- 素数(打表,判断,快速打表)
- poj2739(打表、搜索)
- Assistance Required(打表)
- hdu 4715(打表)
- HDU2098(素数打表)
- HDU2089(打表预处理)
- HDU 5317(打表)
- 数组中出现的次数超过一半的数字(剑指offer面试题39)
- 第一次写博客
- python 文件操作
- 一分钟了解“C语言中在函数名或关键字前加下划线”
- RBAC权限模型
- Sichuan 2017 FSimple Algebra(打表)
- Halcon之HTuple数据和VC数据的相互赋值
- NCURSES程序设计之皇后问题
- 文章解析整理:《从全卷积网络到大型卷积核:深度学习的语义分割全指南》未完
- 09、MySQL函数
- shell插入排序算法
- 一分钟了解“C语言获得文件字节长度”
- java继承关系super用法
- 网络&加密刷题笔记-2