Codechef Tanu and Head-bob

Problem Description

Tanu has got interested in signs and gestures that we use for communication. One such gesture is the head-bob.
When we want to signal "Yes" to someone, we move the head up-and-down. For "No", the head is moved left-and-right, rotating about the vertical axis.
There is a peculiar way of gesturing "Yes", commonly seen in India, by moving head sideways (rotating about the forward-back axis). This is called the Indian head-bob.
Tanu observed many people on the railways station, and made a list of gestures that they made. Usual "Yes" gesture is recorded as "Y", no as "N" and Indian "Yes" gesture as "I". (Assume no foreigner uses the Indian "Yes" gesture and vice-versa). Identify which of them were Indians, which were not Indian, and which one you cannot be sure about.

Input

First line contains T, number of people observed by Tanu.
Each person is described in two lines. First line of the description contains a single integer N, the number of gestures recorded for this person. Next line contains a string of N characters, each character can be "Y", "N" or "I".

Output

For each person, print "INDIAN" if he/she is from India, "NOT INDIAN" if not from India, and "NOT SURE" if the information is insufficient to make a decision.

Constraints

For 30 points: 1 ≤ T,N ≤ 100
For 70 points: 1 ≤ T,N ≤ 1000

Example

Input:

3
5
NNNYY
6
NNINNI
4
NNNN

Output:

NOT INDIAN
INDIAN
NOT SURE

题解

好像就是几行if。
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
int T,a,b,c,n;
char ch[1002];
int main()
{
	scanf("%d",&T);
	while(T--)
	   {scanf("%d",&n);
	    scanf("%s",ch);
	    a=b=c=0;
	    int i;
	    for(i=0;i<n;i++)
	       {if(ch[i]=='I') a++;
		    else if(ch[i]=='Y') b++;
		    else c++;
		   }
		if(a>0&&b==0) {printf("INDIAN\n"); continue;}
		else if(a>0&&b>0) {printf("NOT INDIAN\n"); continue;}
		if(a==0&&b>0) {printf("NOT INDIAN\n"); continue;}
		else {printf("NOT SURE\n"); continue;}
	   }
	return 0;
}
### 回答1: 以下是将经纬度转换为平面坐标系的C代码示例: ```c #include <stdio.h> #include <math.h> #define PI 3.14159265358979323846 #define EARTH_RADIUS 6378137.0 #define EARTH_ECCENTRICITY 0.0818191908426 double rad(double d) { return d * PI / 180.0; } void transform(double wgLat, double wgLon, double *mgLat, double *mgLon) { double mgLat0, mgLon0, mgLat1, mgLon1, mgLat2, mgLon2; double x, y; double sinMG, cosMG, sinMG0, cosMG0, sinU, cosU, tanU, tan2U; double cosSqAlpha, sinSigma, cos2SigmaM, sigma, sinLambda, cosLambda, sinAlpha; double lambda = wgLon; double lat = wgLat; double a = EARTH_RADIUS; double eSquared = EARTH_ECCENTRICITY * EARTH_ECCENTRICITY; double k0 = 0.9996; lat = rad(lat); lambda = rad(lambda); sinMG = sin(lambda); cosMG = cos(lambda); tanU = (1 - eSquared) * tan(lat); tan2U = tanU * tanU; cosSqAlpha = 1 / (1 + tan2U); sinSigma = (1 - eSquared) * sin(lat) * sin(lat) / (1 - eSquared * sin(lat) * sin(lat)); cos2SigmaM = cosSigma - 2 * sinSigma; sigma = atan2(sinSigma, cosSigma); sinU = tanU * cosSigma; cosU = 1 - sinSigma * sinU; tanLambda = sinMG / cosMG; sinAlpha = sqrt(cosSqAlpha) * (tanLambda); cosSqAlpha = 1 - sinAlpha * sinAlpha; cosLambda = 1 / sqrt(1 + tanLambda * tanLambda); sinLambda = tanLambda * cosLambda; mgLat0 = a * ((1 - eSquared / 4 - 3 * eSquared * eSquared / 64 - 5 * eSquared * eSquared * eSquared / 256) * lat - (3 * eSquared / 8 + 3 * eSquared * eSquared / 32 + 45 * eSquared * eSquared * eSquared / 1024) * sin(2 * lat) + (15 * eSquared * eSquared / 256 + 45 * eSquared * eSquared * eSquared / 1024) * sin(4 * lat) - (35 * eSquared * eSquared * eSquared / 3072) * sin(6 * lat)); mgLon0 = a * (cosLambda * sinAlpha * (1 + cosSqAlpha * (-1 + 2 * cosSqAlpha)) * (1 + eSquared * cosSqAlpha * (cosSqAlpha - 2)) + 0.5 / cosLambda * (-sinSigma * (cosSqAlpha - sinAlpha * sinAlpha) + cos2SigmaM * cosLambda * (-1 + 2 * cosSqAlpha))); x = k0 * mgLon0 + 500000; y = k0 * (mgLat0 + mgLat1 + mgLat2) + 0; *mgLat = y; *mgLon = x; ### 回答2: 经纬度和平面坐标系之间的转换是一个常见的问题,可以使用C代码来实现。下面是一个简单的实现示例: ```c #include <stdio.h> #include <math.h> // 定义常量 #define PI 3.141592653589793238462643383279502884 // 将经度转换为弧度 double toRadians(double degree) { return degree * (PI / 180.0); } // 将弧度转换为经度 double toDegrees(double radians) { return radians * (180.0 / PI); } // 经纬度转平面坐标系(球面坐标转直角坐标) void convertLatLonToXY(double lat, double lon, double refLat, double refLon, double *x, double *y) { double earthRadius = 6371000.0; // 地球半径(单位:米) double latRad = toRadians(lat); double lonRad = toRadians(lon); double refLatRad = toRadians(refLat); double refLonRad = toRadians(refLon); double deltaLon = lonRad - refLonRad; *x = earthRadius * deltaLon * cos(refLatRad); *y = earthRadius * (latRad - refLatRad); } // 平面坐标系转经纬度(直角坐标转球面坐标) void convertXYToLatLon(double x, double y, double refLat, double refLon, double *lat, double *lon) { double earthRadius = 6371000.0; double refLatRad = toRadians(refLat); double refLonRad = toRadians(refLon); *lat = toDegrees(y / earthRadius) + refLat; *lon = toDegrees(x / (earthRadius * cos(refLatRad))) + refLon; } // 测试转换函数 int main() { double lat = 31.2304; // 纬度 double lon = 121.4737; // 经度 double refLat = 31.2300; // 参考点纬度 double refLon = 121.4730; // 参考点经度 double x, y; double resultLat, resultLon; // 经纬度转平面坐标系 convertLatLonToXY(lat, lon, refLat, refLon, &x, &y); printf("平面坐标系坐标:x = %lf, y = %lf\n", x, y); // 平面坐标系转经纬度 convertXYToLatLon(x, y, refLat, refLon, &resultLat, &resultLon); printf("经纬度坐标:lat = %lf, lon = %lf\n", resultLat, resultLon); return 0; } ``` 请注意,此代码只是提供了基本的经纬度和平面坐标系转换功能,具体的算法和数学模型可能因应用场景的不同而有所变化。使用时请仔细验证和适应实际需求。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值