Weather Station
来源:互联网 发布:西装定制 知乎 编辑:程序博客网 时间:2024/06/05 11:54
Albert is a well-known inventor. He’s the one who designed an electronic weather
station that periodically track all kinds of weather parameters and records the results
of its measurements. While scanning the records made by the weather station, Albert
discovered one important omission: wind direction data were recorded in one line
without any separator characters. Albert became curious how many different
solutions there would be if he tried to restore the original sequence of measurements.
The inventor wanted you to know that the station distinguishes eight different wind
directions and encodes each one of them with one or two characters. In addition, he
has drawn a picture with wind direction notations used by the weather station.
Your task is to write a program that will calculate the number
of original sequences for a specific record based on weather
station data. Albert realizes that the resulting number may be
quite large, so your task is merely to calculate the value
9
modulo 10 ?+?7.
Limitations
5
The length of the input line does not exceed 10 .
Input
The input file consists of a single line that contains a record made by the weather
station. The record is a line of wind direction values containing characters N, S, W,
and E.
Output
9
Output file must contain integer number of possible solutions modulo 10 ?+?7.
Examples
Input.txt Output.txt
NEWS 2
EWNS 1
Note
The line in the first example has two solutions: {N, E, W, S} and {NE, W, S}.
station that periodically track all kinds of weather parameters and records the results
of its measurements. While scanning the records made by the weather station, Albert
discovered one important omission: wind direction data were recorded in one line
without any separator characters. Albert became curious how many different
solutions there would be if he tried to restore the original sequence of measurements.
The inventor wanted you to know that the station distinguishes eight different wind
directions and encodes each one of them with one or two characters. In addition, he
has drawn a picture with wind direction notations used by the weather station.
Your task is to write a program that will calculate the number
of original sequences for a specific record based on weather
station data. Albert realizes that the resulting number may be
quite large, so your task is merely to calculate the value
9
modulo 10 ?+?7.
Limitations
5
The length of the input line does not exceed 10 .
Input
The input file consists of a single line that contains a record made by the weather
station. The record is a line of wind direction values containing characters N, S, W,
and E.
Output
9
Output file must contain integer number of possible solutions modulo 10 ?+?7.
Examples
Input.txt Output.txt
NEWS 2
EWNS 1
Note
The line in the first example has two solutions: {N, E, W, S} and {NE, W, S}.
The line in the second example has one solution: {E, W, N, S}.
题意:一个气象站观测风向,风向有八个n,w,s,e,nw,ne,sw,se
给你一串字符中间没有空格和其他字符问一共有多少种风向情况
思路:遍历一遍字符串,w,e没用,当遍历到s,n时如果后边含有w或者e乘2,边算边取余
ac代码:
#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>#include <cmath>const long long maxn=1000000007;using namespace std;int main(){ freopen("input.txt","r",stdin); freopen("output.txt","w",stdout); char a[100005]; while(gets(a)) { int len=strlen(a); long long sum=1; for(int i=0;i<len;i++) { if(a[i]=='N') { if(a[i+1]=='E'||a[i+1]=='W') {sum=(sum*2)%maxn; i++; } } if(a[i]=='S') { if(a[i+1]=='E'||a[i+1]=='W') { sum=(sum*2)%maxn; i++; } } } printf("%lld\n",sum); } return 0;}
0 0
- Weather Station
- Weather Station(字符串)
- Weather Station DP
- weather
- weather
- Weather
- weather glossary
- Weather Report
- googole weather
- weather jp
- Weather Forecast
- xml weather
- weather.xml
- The weather
- Hot Weather
- gsoap weather
- Weather report
- WebServices/Weather/
- ZJOI2008_骑士_基环树&&dp
- TensorFlow 实战(三)—— 实现常见公式
- EasyDarwin幼教云视频平台在幼教平台领域大放异彩!
- 排队买票的问题
- JAVA interrupt、interrupted和isInterrupted的区别
- Weather Station
- bzoj 1119: [POI2009]SLO 置换群
- Spring+SpringMvc+Hibernate整合问题
- 欢迎使用CSDN-markdown编辑器
- USB2.0 PCB布线关键与经验教训
- CCTV摄像头/MVPower DVR扫描器
- Spring Boot Admin官方文档阅读笔记
- 详解java设计模式整理列表
- 剑指offer 用两个栈实现队列